Skip to content

Upgrade to Rust 2024 edition + bump MSRV #906

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

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changes/edition-2024.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-tauri-app": patch
---

Upgrade CLI and templates to Rust 2024 edition.
2 changes: 1 addition & 1 deletion .github/workflows/cli-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
toolchain: [1.71, stable]
toolchain: [1.85, stable]

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name = "create-tauri-app"
description = "Rapidly scaffold out a new tauri app project."
authors = ["Tauri Programme within The Commons Conservancy"]
version = "4.6.0"
edition = "2021"
edition = "2024"
license = "Apache-2.0 OR MIT"
readme = "README.md"
repository = "https://github.com/tauri-apps/create-tauri-app"
keywords = ["tauri"]
categories = ["gui"]
exclude = ["node", "worker", ".github", ".changes", ".scripts"]
rust-version = "1.71"
rust-version = "1.85"

[[bin]]
name = "cargo-create-tauri-app"
Expand Down
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
edition = "2021"
edition = "2024"
name = "create-tauri-app-node"
version = "0.0.0"
license = "Apache-2.0 OR MIT"
Expand Down
72 changes: 50 additions & 22 deletions src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,37 @@ pub fn print_missing_deps(
let deps: &[Dep<'_>] = &[
Dep {
name: "Rust",
instruction: format!("Visit {BLUE}{BOLD}https://www.rust-lang.org/learn/get-started#installing-rust{RESET}"),
instruction: format!(
"Visit {BLUE}{BOLD}https://www.rust-lang.org/learn/get-started#installing-rust{RESET}"
),
exists: &|| rustc_installed && cargo_installed,
skip: rustc_installed || cargo_installed,
},
Dep {
Dep {
name: "rustc",
instruction: format!("Visit {BLUE}{BOLD}https://www.rust-lang.org/learn/get-started#installing-rust{RESET} to install Rust"),
instruction: format!(
"Visit {BLUE}{BOLD}https://www.rust-lang.org/learn/get-started#installing-rust{RESET} to install Rust"
),
exists: &|| rustc_installed,
skip: !rustc_installed && !cargo_installed,
},
Dep {
name: "Cargo",
instruction: format!("Visit {BLUE}{BOLD}https://www.rust-lang.org/learn/get-started#installing-rust{RESET} to install Rust"),
instruction: format!(
"Visit {BLUE}{BOLD}https://www.rust-lang.org/learn/get-started#installing-rust{RESET} to install Rust"
),
exists: &|| cargo_installed,
skip: !rustc_installed && !cargo_installed,
},
Dep {
name: "Tauri CLI",
instruction: match tauri_version {
TauriVersion::V1 => format!("Run `{BLUE}{BOLD}cargo install tauri-cli --version '^1.0.0' --locked{RESET}`"),
TauriVersion::V2 => format!("Run `{BLUE}{BOLD}cargo install tauri-cli --version '^2.0.0' --locked{RESET}`"),
TauriVersion::V1 => format!(
"Run `{BLUE}{BOLD}cargo install tauri-cli --version '^1.0.0' --locked{RESET}`"
),
TauriVersion::V2 => format!(
"Run `{BLUE}{BOLD}cargo install tauri-cli --version '^2.0.0' --locked{RESET}`"
),
},
exists: &|| is_tauri_cli_installed(tauri_version),
skip: pkg_manager.is_node() || !template.needs_tauri_cli(),
Expand All @@ -190,7 +200,9 @@ pub fn print_missing_deps(
},
Dep {
name: "wasm32 target",
instruction: format!("Run `{BLUE}{BOLD}rustup target add wasm32-unknown-unknown{RESET}`"),
instruction: format!(
"Run `{BLUE}{BOLD}rustup target add wasm32-unknown-unknown{RESET}`"
),
exists: &is_wasm32_installed,
skip: pkg_manager.is_node() || !template.needs_wasm32_target(),
},
Expand All @@ -215,7 +227,9 @@ pub fn print_missing_deps(
#[cfg(windows)]
Dep {
name: "Webview2",
instruction: format!("Visit {BLUE}{BOLD}https://go.microsoft.com/fwlink/p/?LinkId=2124703{RESET}"),
instruction: format!(
"Visit {BLUE}{BOLD}https://go.microsoft.com/fwlink/p/?LinkId=2124703{RESET}"
),
exists: &is_webview2_installed,
skip: false,
},
Expand All @@ -228,10 +242,14 @@ pub fn print_missing_deps(
))]
Dep {
name: "webkit2gtk & rsvg2",
instruction: format!("Visit {BLUE}{BOLD}{}{RESET}", match tauri_version {
TauriVersion::V1 => "https://v1.tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux",
TauriVersion::V2 => "https://tauri.app/guides/prerequisites/#linux",
}),
instruction: format!(
"Visit {BLUE}{BOLD}{}{RESET}",
match tauri_version {
TauriVersion::V1 =>
"https://v1.tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux",
TauriVersion::V2 => "https://tauri.app/guides/prerequisites/#linux",
}
),
exists: &|| webkit2gtk_installed && rsvg2_installed,
skip: webkit2gtk_installed || rsvg2_installed,
},
Expand All @@ -244,10 +262,14 @@ pub fn print_missing_deps(
))]
Dep {
name: "webkit2gtk",
instruction: format!("Visit {BLUE}{BOLD}{}{RESET}", match tauri_version {
TauriVersion::V1 => "https://v1.tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux",
TauriVersion::V2 => "https://tauri.app/guides/prerequisites/#linux",
}),
instruction: format!(
"Visit {BLUE}{BOLD}{}{RESET}",
match tauri_version {
TauriVersion::V1 =>
"https://v1.tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux",
TauriVersion::V2 => "https://tauri.app/guides/prerequisites/#linux",
}
),
exists: &|| webkit2gtk_installed,
skip: !rsvg2_installed && !webkit2gtk_installed,
},
Expand All @@ -260,10 +282,14 @@ pub fn print_missing_deps(
))]
Dep {
name: "rsvg2",
instruction: format!("Visit {BLUE}{BOLD}{}{RESET}", match tauri_version {
TauriVersion::V1 => "https://v1.tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux",
TauriVersion::V2 => "https://tauri.app/guides/prerequisites/#linux",
}),
instruction: format!(
"Visit {BLUE}{BOLD}{}{RESET}",
match tauri_version {
TauriVersion::V1 =>
"https://v1.tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux",
TauriVersion::V2 => "https://tauri.app/guides/prerequisites/#linux",
}
),
exists: &|| rsvg2_installed,
skip: !rsvg2_installed && !webkit2gtk_installed,
},
Expand All @@ -279,7 +305,7 @@ pub fn print_missing_deps(
instruction: format!("Visit {BLUE}{BOLD}https://dotnet.microsoft.com/download{RESET}"),
exists: &|| is_cli_installed("dotnet", "--info"),
skip: !template.needs_dotnet() || pkg_manager.is_node(),
}
},
];

let missing_deps: Vec<(&str, &str)> = deps
Expand All @@ -306,7 +332,9 @@ pub fn print_missing_deps(
});

if !missing_deps.is_empty() {
println!("\n\nYour system is {YELLOW}missing dependencies{RESET} (or they do not exist in {YELLOW}$PATH{RESET}):");
println!(
"\n\nYour system is {YELLOW}missing dependencies{RESET} (or they do not exist in {YELLOW}$PATH{RESET}):"
);
for (index, (name, instruction)) in missing_deps.iter().enumerate() {
if index == 0 {
println!(
Expand Down
19 changes: 15 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,18 @@ where
// is valid, otherwise, we error and exit
if !pkg_manager.templates().contains(&template) {
eprintln!(
"{BOLD}{RED}error{RESET}: the {GREEN}{template}{RESET} template is not suppported for the {GREEN}{pkg_manager}{RESET} package manager\n possible templates for {GREEN}{pkg_manager}{RESET} are: [{}]\n or maybe you meant to use another package manager\n possible package managers for {GREEN}{template}{RESET} are: [{}]" ,
templates_no_flavors.iter().map(|e|format!("{GREEN}{e}{RESET}")).collect::<Vec<_>>().join(", "),
template.possible_package_managers().iter().map(|e|format!("{GREEN}{e}{RESET}")).collect::<Vec<_>>().join(", "),
"{BOLD}{RED}error{RESET}: the {GREEN}{template}{RESET} template is not suppported for the {GREEN}{pkg_manager}{RESET} package manager\n possible templates for {GREEN}{pkg_manager}{RESET} are: [{}]\n or maybe you meant to use another package manager\n possible package managers for {GREEN}{template}{RESET} are: [{}]",
templates_no_flavors
.iter()
.map(|e| format!("{GREEN}{e}{RESET}"))
.collect::<Vec<_>>()
.join(", "),
template
.possible_package_managers()
.iter()
.map(|e| format!("{GREEN}{e}{RESET}"))
.collect::<Vec<_>>()
.join(", "),
);
exit(1);
}
Expand Down Expand Up @@ -343,7 +352,9 @@ where
TauriVersion::V2 => "https://tauri.app/start/prerequisites/",
};

println!("Make sure you have installed the prerequisites for your OS: {BLUE}{BOLD}{prereqs_url}{RESET}, then run:");
println!(
"Make sure you have installed the prerequisites for your OS: {BLUE}{BOLD}{prereqs_url}{RESET}, then run:"
);
} else {
println!(" To get started run:")
}
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use anyhow::{bail, Context};
use anyhow::{Context, bail};

#[derive(Default, Clone, PartialEq, Eq, Debug)]
pub struct Manifest<'a> {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/dialoguer_theme.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt;

use dialoguer::{
console::{style, Style, StyledObject},
console::{Style, StyledObject, style},
theme::Theme,
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/lte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ enum Stmt<'a> {
},
}

impl<'a> Stmt<'a> {
impl Stmt<'_> {
fn execute<V, T>(&self, out: &mut T, data: &HashMap<&str, V>) -> Result<()>
where
T: Write,
Expand Down
2 changes: 1 addition & 1 deletion templates/_base_/src-tauri/Cargo.toml.lte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "{% package_name %}"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
edition = "2024"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion templates/template-dioxus/Cargo.toml.lte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "{% package_name %}-ui"
version = "0.1.0"
edition = "2021"
edition = "2024"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion templates/template-leptos/Cargo.toml.lte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "{% package_name %}-ui"
version = "0.1.0"
edition = "2021"
edition = "2024"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion templates/template-sycamore/Cargo.toml.lte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "{% package_name %}-ui"
version = "0.1.0"
edition = "2021"
edition = "2024"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion templates/template-yew/Cargo.toml.lte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "{% package_name %}-ui"
version = "0.1.0"
edition = "2021"
edition = "2024"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
Expand Down
Loading