Skip to content

Commit 7ee3aaa

Browse files
authored
fix: allow building on msrv 1.57 (#170)
1 parent 975a851 commit 7ee3aaa

9 files changed

Lines changed: 74 additions & 16 deletions

File tree

.changes/msrv-1.57.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-tauri-app": "patch"
3+
---
4+
5+
Fix build on MSRV 1.57.

.changes/next.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
"create-tauri-app": "patch"
3+
"create-tauri-app-js": "patch"
34
---
45

56
Fix building in `next` and `next-ts` templates by removing the `experimental` option from `next.config.js` since `images.unoptimized` is now stable.

.github/workflows/cli-test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@ concurrency:
3030
jobs:
3131
test:
3232
runs-on: ubuntu-latest
33+
strategy:
34+
matrix:
35+
toolchain: [1.57, stable]
3336

3437
steps:
3538
- uses: actions/checkout@v2
3639

3740
- name: install stable
3841
uses: actions-rs/toolchain@v1
3942
with:
40-
toolchain: stable
43+
toolchain: ${{ matrix.toolchain }}
4144
override: true
4245

4346
- uses: actions-rs/cargo@v1

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ panic = "abort"
66
codegen-units = 1
77
lto = true
88
opt-level = "s"
9-
strip = true

packages/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ repository = "https://github.com/tauri-apps/create-tauri-app"
1010
keywords = [ "tauri" ]
1111
categories = [ "gui" ]
1212
exclude = [ "/node" ]
13+
rust-version = "1.57"
1314

1415
[[bin]]
1516
name = "cargo-create-tauri-app"

packages/cli/src/cli.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ pub fn parse(argv: Vec<OsString>, bin_name: Option<String>) -> anyhow::Result<Ar
5656
desc = env!("CARGO_PKG_DESCRIPTION"),
5757
managers = PackageManager::ALL
5858
.iter()
59-
.map(|e| format!("{GREEN}{e}{RESET}"))
59+
.map(|e| format!("{}{}{}", GREEN, e, RESET))
6060
.collect::<Vec<_>>()
6161
.join(", "),
6262
fragments = Template::ALL
6363
.iter()
64-
.map(|e| format!("{GREEN}{e}{RESET}"))
64+
.map(|e| format!("{}{}{}", GREEN, e, RESET))
6565
.collect::<Vec<_>>()
6666
.join(", "),
67+
GREEN = GREEN,
68+
RESET = RESET,
69+
YELLOW = YELLOW,
6770
);
6871

6972
println!("{}", help);

packages/cli/src/lib.rs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ where
1818
A: Into<OsString> + Clone,
1919
{
2020
if let Err(e) = try_run(args, bin_name) {
21-
eprintln!("{BOLD}{RED}error{RESET}: {e:#}");
21+
eprintln!(
22+
"{BOLD}{RED}error{RESET}: {:#}",
23+
e,
24+
BOLD = BOLD,
25+
RED = RED,
26+
RESET = RESET
27+
);
2228
exit(1);
2329
}
2430
}
@@ -95,7 +101,12 @@ where
95101
.interact()?
96102
};
97103
if !overrwite {
98-
eprintln!("{BOLD}{RED}✘{RESET} Operation Cancelled");
104+
eprintln!(
105+
"{BOLD}{RED}✘{RESET} Operation Cancelled",
106+
BOLD = BOLD,
107+
RED = RED,
108+
RESET = RESET
109+
);
99110
exit(1);
100111
}
101112
};
@@ -132,8 +143,14 @@ where
132143

133144
if !templates.contains(&template) {
134145
eprintln!(
135-
"{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: [{}]",
136-
templates.iter().map(|e|format!("{GREEN}{e}{RESET}")).collect::<Vec<_>>().join(", ")
146+
"{BOLD}{RED}error{RESET}: the {GREEN}{}{RESET} template is not suppported for the {GREEN}{pkg_manager}{RESET} package manager\n possible templates for {GREEN}{pkg_manager}{RESET} are: [{}]",
147+
template,
148+
templates.iter().map(|e|format!("{GREEN}{}{RESET}", e, GREEN = GREEN, RESET = RESET)).collect::<Vec<_>>().join(", "),
149+
pkg_manager = pkg_manager,
150+
BOLD = BOLD,
151+
RED = RED,
152+
RESET = RESET,
153+
GREEN = GREEN,
137154
);
138155
exit(1);
139156
}
@@ -147,7 +164,15 @@ where
147164
template.render(&target_dir, pkg_manager, &package_name)?;
148165

149166
println!();
150-
println!("{ITALIC}{DIM}Please follow{DIMRESET} {BLUE}https://tauri.app/v1/guides/getting-started/prerequisites{WHITE} {DIM}to install the needed prerequisites, if you haven't already.{DIMRESET}{RESET}");
167+
println!(
168+
"{ITALIC}{DIM}Please follow{DIMRESET} {BLUE}https://tauri.app/v1/guides/getting-started/prerequisites{WHITE} {DIM}to install the needed prerequisites, if you haven't already.{DIMRESET}{RESET}",
169+
ITALIC = ITALIC,
170+
DIM = DIM,
171+
DIMRESET = DIMRESET,
172+
WHITE = WHITE,
173+
BLUE = BLUE,
174+
RESET=RESET
175+
);
151176
if let Some(info) = template.post_init_info() {
152177
println!("{}", info);
153178
}

packages/cli/src/package_manager.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ use std::{fmt::Display, str::FromStr};
66

77
use crate::template::Template;
88

9-
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
9+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1010
#[non_exhaustive]
1111
pub enum PackageManager {
12-
#[default]
1312
Cargo,
1413
Pnpm,
1514
Yarn,
1615
Npm,
1716
}
1817

18+
impl Default for PackageManager {
19+
fn default() -> Self {
20+
PackageManager::Cargo
21+
}
22+
}
23+
1924
impl<'a> PackageManager {
2025
pub const ALL: &'a [PackageManager] = &[
2126
PackageManager::Cargo,

packages/cli/src/template.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ use crate::{colors::*, package_manager::PackageManager};
1313
#[folder = "$CARGO_MANIFEST_DIR/fragments"]
1414
struct Fragments;
1515

16-
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
16+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1717
#[non_exhaustive]
1818
pub enum Template {
19-
#[default]
2019
Vanilla,
2120
VanillaTs,
2221
Vue,
@@ -34,6 +33,12 @@ pub enum Template {
3433
PreactTs,
3534
}
3635

36+
impl Default for Template {
37+
fn default() -> Self {
38+
Template::Vanilla
39+
}
40+
}
41+
3742
impl<'a> Template {
3843
pub const ALL: &'a [Template] = &[
3944
Template::Vanilla,
@@ -55,7 +60,18 @@ impl<'a> Template {
5560

5661
pub fn post_init_info(&self) -> Option<String> {
5762
match self {
58-
Template::Yew => Some(format!("{ITALIC}{DIM}You also need to install{DIMRESET} {YELLOW}tauri-cli{WHITE} {DIM}({DIMRESET}{BLUE}cargo install tauri-cli{WHITE}{DIM}) and{DIMRESET} {YELLOW}trunk{WHITE} {DIM}({DIMRESET}{BLUE}https://trunkrs.dev/#install{WHITE}{DIM}){DIMRESET}{RESET}")),
63+
Template::Yew => Some(
64+
format!(
65+
"{ITALIC}{DIM}You also need to install{DIMRESET} {YELLOW}tauri-cli{WHITE} {DIM}({DIMRESET}{BLUE}cargo install tauri-cli{WHITE}{DIM}) and{DIMRESET} {YELLOW}trunk{WHITE} {DIM}({DIMRESET}{BLUE}https://trunkrs.dev/#install{WHITE}{DIM}){DIMRESET}{RESET}",
66+
ITALIC = ITALIC,
67+
DIM = DIM,
68+
DIMRESET = DIMRESET,
69+
YELLOW = YELLOW,
70+
WHITE = WHITE,
71+
BLUE = BLUE,
72+
RESET = RESET
73+
),
74+
),
5975
_ => None,
6076
}
6177
}
@@ -166,15 +182,15 @@ impl<'a> Template {
166182
.next()
167183
.unwrap()
168184
.as_os_str()
169-
== path::PathBuf::from(format!("fragment-{self}"))
185+
== path::PathBuf::from(format!("fragment-{}", self))
170186
}) {
171187
write_file(&file)?;
172188
}
173189

174190
// then write extra files specified in the fragment manifest
175191
for (src, dest) in manifest.files {
176192
let data = Fragments::get(&format!("_assets_/{}", src))
177-
.with_context(|| format!("Failed to get asset file bytes: {src}"))?
193+
.with_context(|| format!("Failed to get asset file bytes: {}", src))?
178194
.data;
179195
let dest = target_dir.join(dest);
180196
let parent = dest.parent().unwrap();

0 commit comments

Comments
 (0)