Skip to content

Commit d34ff53

Browse files
authored
feat: tauri v2 RC (#746)
1 parent 4eddf49 commit d34ff53

58 files changed

Lines changed: 176 additions & 195 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changes/rc.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"create-tauri-app": minor
3+
"create-tauri-app-js": minor
4+
---
5+
6+
Updated the templates to Tauri v2 RC.

.github/workflows/templates-test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,24 @@ jobs:
9999
- uses: dtolnay/rust-toolchain@stable
100100

101101
- run: cargo install tauri-cli
102-
if: (matrix.settings.manager == 'cargo' || matrix.settings.manager == 'dotnet') && matrix.settings.beta != true
102+
if: (matrix.settings.manager == 'cargo' || matrix.settings.manager == 'dotnet') && matrix.settings.rc != true
103103

104-
- run: cargo install tauri-cli --version '^2.0.0-beta'
105-
if: (matrix.settings.manager == 'cargo' || matrix.settings.manager == 'dotnet') && matrix.settings.beta == true
104+
- run: cargo install tauri-cli --version '^2.0.0-rc'
105+
if: (matrix.settings.manager == 'cargo' || matrix.settings.manager == 'dotnet') && matrix.settings.rc == true
106106

107107
- run: |
108108
rustup target add wasm32-unknown-unknown
109109
cargo install --locked trunk
110110
if: matrix.settings.install_trunk
111111
112112
- name: install system dependencies
113-
if: matrix.settings.beta != true
113+
if: matrix.settings.rc != true
114114
run: |
115115
sudo apt-get update
116116
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
117117
118-
- name: install system dependencies (beta)
119-
if: matrix.settings.beta == true
118+
- name: install system dependencies (rc)
119+
if: matrix.settings.rc == true
120120
run: |
121121
sudo apt-get update
122122
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.1 libayatana-appindicator3-dev librsvg2-dev patchelf

.scripts/generate-templates-matrix.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ matrixConfig
7878
const jobInfo = {
7979
template: t,
8080
install_trunk: ["yew", "sycamore", "leptos"].includes(t),
81-
beta: false,
81+
rc: false,
8282
no_bundle_flag: "-b none",
8383
...managerInfo,
8484
};
8585
outMatrix.push(jobInfo);
8686
outMatrix.push({
8787
...jobInfo,
88-
beta: true,
88+
rc: true,
8989
no_bundle_flag: "--no-bundle",
90-
flags: "--beta",
90+
flags: "--rc",
9191
});
9292
}
9393
}

src/args.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct Args {
1515
pub template: Option<Template>,
1616
pub skip: bool,
1717
pub force: bool,
18-
pub beta: bool,
18+
pub rc: bool,
1919
pub mobile: Option<bool>,
2020
pub no_mobile: Option<bool>,
2121
}
@@ -28,7 +28,7 @@ impl Default for Args {
2828
template: Some(Template::Vanilla),
2929
skip: false,
3030
force: false,
31-
beta: false,
31+
rc: false,
3232
mobile: Some(false), // default for this value must be Some(false), as we use it as fallback when -y is used
3333
no_mobile: None,
3434
}
@@ -56,9 +56,9 @@ pub fn parse(argv: Vec<OsString>, bin_name: Option<String>) -> anyhow::Result<Ar
5656
{GREEN}-t{RESET}, {GREEN}--template <TEMPLATE>{RESET} Specify the UI template to use [{templates}]
5757
{GREEN}-y{RESET}, {GREEN}--yes{RESET} Skip prompts and use defaults where applicable
5858
{GREEN}-f{RESET}, {GREEN}--force{RESET} Force create the directory even if it is not empty.
59-
{GREEN}--beta{RESET} Bootstraps a project using tauri@2.0-beta
60-
{GREEN}--mobile{RESET} Bootstraps a mobile project too. Only availabe with `--beta` option.
61-
{GREEN}--no-mobile{RESET} Skip bootstraping a mobile project. Only availabe with `--beta` option.
59+
{GREEN}--rc{RESET} Bootstraps a project using tauri@2.0-rc.
60+
{GREEN}--mobile{RESET} Bootstraps a mobile project too. Only availabe with `--rc` option.
61+
{GREEN}--no-mobile{RESET} Skip bootstraping a mobile project. Only availabe with `--rc` option.
6262
{GREEN}-h{RESET}, {GREEN}--help{RESET} Prints help information
6363
{GREEN}-v{RESET}, {GREEN}--version{RESET} Prints version information
6464
"#,
@@ -87,21 +87,26 @@ pub fn parse(argv: Vec<OsString>, bin_name: Option<String>) -> anyhow::Result<Ar
8787
}
8888

8989
// pargs.contains() consume the flag so we have to bind the bool to a variable.
90-
let beta = if pargs.contains("--alpha") {
90+
let rc = if pargs.contains("--alpha") {
9191
eprintln!(
92-
"{BOLD}{YELLOW}warning{RESET}: The `{GREEN}--alpha{RESET}` option is now an alias for `{GREEN}--beta{RESET}` and may be removed in the future."
92+
"{BOLD}{YELLOW}warning{RESET}: The `{GREEN}--alpha{RESET}` option is now an alias for `{GREEN}--rc{RESET}` and may be removed in the future."
93+
);
94+
true
95+
} else if pargs.contains("--beta") {
96+
eprintln!(
97+
"{BOLD}{YELLOW}warning{RESET}: The `{GREEN}--beta{RESET}` option is now an alias for `{GREEN}--rc{RESET}` and may be removed in the future."
9398
);
9499
true
95100
} else {
96-
pargs.contains("--beta")
101+
pargs.contains("--rc")
97102
};
98103

99104
let args = Args {
100105
manager: pargs.opt_value_from_str(["-m", "--manager"])?,
101106
template: pargs.opt_value_from_str(["-t", "--template"])?,
102107
skip: pargs.contains(["-y", "--yes"]),
103108
force: pargs.contains(["-f", "--force"]),
104-
beta,
109+
rc,
105110
mobile: if pargs.contains("--mobile") {
106111
Some(true)
107112
} else {

src/deps.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ fn is_trunk_installed() -> bool {
3737
.unwrap_or(false)
3838
}
3939

40-
fn is_appropriate_tauri_cli_installed(beta: bool) -> bool {
40+
fn is_appropriate_tauri_cli_installed(rc: bool) -> bool {
4141
let check = |o: Output| match o.status.success() {
4242
true => String::from_utf8_lossy(&o.stdout)
4343
.split_once(' ')
44-
.map(|(_, v)| v.starts_with(if beta { '2' } else { '1' }))
44+
.map(|(_, v)| v.starts_with(if rc { '2' } else { '1' }))
4545
.unwrap_or(false),
4646
s => s,
4747
};
@@ -111,9 +111,9 @@ fn is_webview2_installed() -> bool {
111111
target_os = "openbsd",
112112
target_os = "netbsd"
113113
))]
114-
fn is_webkit2gtk_installed(beta: bool) -> bool {
114+
fn is_webkit2gtk_installed(rc: bool) -> bool {
115115
Command::new("pkg-config")
116-
.arg(if beta {
116+
.arg(if rc {
117117
"webkit2gtk-4.1"
118118
} else {
119119
"webkit2gtk-4.0"
@@ -163,7 +163,7 @@ struct Dep<'a> {
163163
}
164164

165165
/// Print missing deps in a table and returns whether there was any missing deps.
166-
pub fn print_missing_deps(pkg_manager: PackageManager, template: Template, beta: bool) -> bool {
166+
pub fn print_missing_deps(pkg_manager: PackageManager, template: Template, rc: bool) -> bool {
167167
let rustc_installed = is_rustc_installed();
168168
let cargo_installed = is_cargo_installed();
169169

@@ -175,7 +175,7 @@ pub fn print_missing_deps(pkg_manager: PackageManager, template: Template, beta:
175175
target_os = "netbsd"
176176
))]
177177
let (webkit2gtk_installed, rsvg2_installed) =
178-
(is_webkit2gtk_installed(beta), is_rsvg2_installed());
178+
(is_webkit2gtk_installed(rc), is_rsvg2_installed());
179179

180180
let deps: &[Dep<'_>] = &[
181181
Dep {
@@ -198,12 +198,12 @@ pub fn print_missing_deps(pkg_manager: PackageManager, template: Template, beta:
198198
},
199199
Dep {
200200
name: "Tauri CLI",
201-
instruction: if beta {
202-
format!("Run `{BLUE}{BOLD}cargo install tauri-cli --version '^2.0.0-beta'{RESET}`")
201+
instruction: if rc {
202+
format!("Run `{BLUE}{BOLD}cargo install tauri-cli --version '^2.0.0-rc'{RESET}`")
203203
} else {
204204
format!("Run `{BLUE}{BOLD}cargo install tauri-cli{RESET}`")
205205
},
206-
exists: &|| is_appropriate_tauri_cli_installed(beta),
206+
exists: &|| is_appropriate_tauri_cli_installed(rc),
207207
skip: pkg_manager.is_node() || !template.needs_tauri_cli(),
208208
},
209209
Dep {
@@ -240,8 +240,8 @@ pub fn print_missing_deps(pkg_manager: PackageManager, template: Template, beta:
240240
))]
241241
Dep {
242242
name: "webkit2gtk & rsvg2",
243-
instruction: format!("Visit {BLUE}{BOLD}{}{RESET}", if beta {
244-
"https://beta.tauri.app/guides/prerequisites/#linux"
243+
instruction: format!("Visit {BLUE}{BOLD}{}{RESET}", if rc {
244+
"https://v2.tauri.app/guides/prerequisites/#linux"
245245
} else {
246246
"https://tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux"
247247
}),
@@ -257,8 +257,8 @@ pub fn print_missing_deps(pkg_manager: PackageManager, template: Template, beta:
257257
))]
258258
Dep {
259259
name: "webkit2gtk",
260-
instruction: format!("Visit {BLUE}{BOLD}{}{RESET}", if beta {
261-
"https://beta.tauri.app/guides/prerequisites/#linux"
260+
instruction: format!("Visit {BLUE}{BOLD}{}{RESET}", if rc {
261+
"https://v2.tauri.app/guides/prerequisites/#linux"
262262
} else {
263263
"https://tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux"
264264
}),
@@ -274,8 +274,8 @@ pub fn print_missing_deps(pkg_manager: PackageManager, template: Template, beta:
274274
))]
275275
Dep {
276276
name: "rsvg2",
277-
instruction: format!("Visit {BLUE}{BOLD}{}{RESET}", if beta {
278-
"https://beta.tauri.app/guides/prerequisites/#linux"
277+
instruction: format!("Visit {BLUE}{BOLD}{}{RESET}", if rc {
278+
"https://v2.tauri.app/guides/prerequisites/#linux"
279279
} else {
280280
"https://tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux"
281281
}),

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,23 @@ where
6868
skip,
6969
mut mobile,
7070
no_mobile,
71-
beta,
71+
rc,
7272
manager,
7373
project_name,
7474
template,
7575
force,
7676
} = args;
7777
let cwd = std::env::current_dir()?;
7878

79-
// Allow `--mobile` to only be used with `--beta` for now
79+
// Allow `--mobile` to only be used with `--rc` for now
8080
// TODO: remove this limitation once tauri@v2 is stable
81-
if (mobile.is_some() || no_mobile.is_some()) && !beta {
81+
if (mobile.is_some() || no_mobile.is_some()) && !rc {
8282
let flag = if mobile.is_some() {
8383
"--mobile"
8484
} else {
8585
"--no-mobile"
8686
};
87-
eprintln!("{BOLD}{RED}error{RESET}: `{GREEN}{}{RESET}` option is only available if `{GREEN}--beta{RESET}` option is also used", flag);
87+
eprintln!("{BOLD}{RED}error{RESET}: `{GREEN}{}{RESET}` option is only available if `{GREEN}--rc{RESET}` option is also used", flag);
8888
exit(1);
8989
}
9090

@@ -287,12 +287,12 @@ where
287287
};
288288

289289
// Prompt for wether to bootstrap a mobile-friendly tauri project
290-
// This should only be prompted if `--beta` is used on the command line and `--mobile` wasn't.
290+
// This should only be prompted if `--rc` is used on the command line and `--mobile` wasn't.
291291
// TODO: remove this limitation once tauri@v2 is stable
292292
let mobile = match mobile {
293293
Some(mobile) => mobile,
294294
None => {
295-
if skip || !beta {
295+
if skip || !rc {
296296
defaults.mobile.context("default mobile not set")?
297297
} else {
298298
Confirm::with_theme(&ColorfulTheme::default())
@@ -344,14 +344,14 @@ where
344344
pkg_manager,
345345
&project_name,
346346
&package_name,
347-
beta,
347+
rc,
348348
mobile,
349349
)?;
350350

351351
// Print post-render instructions
352352
println!();
353353
print!("Template created!");
354-
let has_missing = print_missing_deps(pkg_manager, template, beta);
354+
let has_missing = print_missing_deps(pkg_manager, template, rc);
355355
if has_missing {
356356
println!("Make sure you have installed the prerequisites for your OS: {BLUE}{BOLD}https://tauri.app/v1/guides/getting-started/prerequisites{RESET}, then run:");
357357
} else {

src/template.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl<'a> Template {
256256
pkg_manager: PackageManager,
257257
project_name: &str,
258258
package_name: &str,
259-
beta: bool,
259+
rc: bool,
260260
mobile: bool,
261261
) -> anyhow::Result<()> {
262262
let manifest_bytes =
@@ -270,9 +270,9 @@ impl<'a> Template {
270270
let lib_name = format!("{}_lib", package_name.replace('-', "_"));
271271
let project_name_pascal_case = Self::transform_to_pascal_case(project_name.to_string());
272272

273-
let beta_str = beta.to_string();
273+
let rc_str = rc.to_string();
274274
let manifest_template_data: HashMap<&str, &str> = [
275-
("beta", beta_str.as_str()),
275+
("rc", rc_str.as_str()),
276276
("pkg_manager_run_command", pkg_manager.run_cmd()),
277277
("lib_name", &lib_name),
278278
("package_name", package_name),
@@ -297,8 +297,8 @@ impl<'a> Template {
297297
)?;
298298

299299
let template_data: HashMap<&str, String> = [
300-
("stable", (!beta).to_string()),
301-
("beta", beta_str.clone()),
300+
("stable", (!rc).to_string()),
301+
("rc", rc_str.clone()),
302302
("mobile", mobile.to_string()),
303303
("project_name", project_name.to_string()),
304304
(
@@ -376,8 +376,8 @@ impl<'a> Template {
376376
// conditional files:
377377
// are files that start with a special syntax
378378
// "%(<list of flags separated by `-`>%)<file_name>"
379-
// flags are supported package managers, stable, beta and mobile.
380-
// example: "%(pnpm-npm-yarn-stable-beta)%package.json"
379+
// flags are supported package managers, stable, rc and mobile.
380+
// example: "%(pnpm-npm-yarn-stable-rc)%package.json"
381381
name if name.starts_with("%(") && name[1..].contains(")%") => {
382382
let mut s = name.strip_prefix("%(").unwrap().split(")%");
383383
let (mut flags, name) = (
@@ -386,16 +386,16 @@ impl<'a> Template {
386386
);
387387

388388
let for_stable = flags.contains(&"stable");
389-
let for_beta = flags.contains(&"beta");
389+
let for_rc = flags.contains(&"rc");
390390
let for_mobile = flags.contains(&"mobile");
391391

392392
// remove these flags to only keep package managers flags
393-
flags.retain(|e| !["stable", "beta", "mobile"].contains(e));
393+
flags.retain(|e| !["stable", "rc", "mobile"].contains(e));
394394

395-
if ((for_stable && !beta)
396-
|| (for_beta && beta && !mobile)
397-
|| (for_mobile && beta && mobile)
398-
|| (!for_stable && !for_beta && !for_mobile))
395+
if ((for_stable && !rc)
396+
|| (for_rc && rc && !mobile)
397+
|| (for_mobile && rc && mobile)
398+
|| (!for_stable && !for_rc && !for_mobile))
399399
&& (flags.contains(&pkg_manager.to_string().as_str()) || flags.is_empty())
400400
{
401401
name

src/utils/lte.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,19 +508,19 @@ mod tests {
508508
<html>
509509
<h1>Hello<h2>{% if alpha %}
510510
<em>{% alpha_str %}</em>{% else %}
511-
<em>{% if beta %}beta{%else%}stable{%endif%}</em>{% endif %}
511+
<em>{% if rc %}rc{%else%}stable{%endif%}</em>{% endif %}
512512
</html>"#;
513513
let data: HashMap<&str, &str> = [
514514
("alpha", "false"),
515-
("beta", "true"),
515+
("rc", "true"),
516516
("alpha_str", "holla alpha"),
517517
]
518518
.into();
519519
let rendered = render(template, &data).expect("it should render");
520520
let expected = r#"
521521
<html>
522522
<h1>Hello<h2>
523-
<em>beta</em>
523+
<em>rc</em>
524524
</html>"#;
525525
assert_eq!(rendered, expected)
526526
}

templates/_base_/src-tauri/%(beta-mobile)%tauri.conf.json.lte renamed to templates/_base_/src-tauri/%(rc-mobile)%tauri.conf.json.lte

File renamed without changes.

templates/_base_/src-tauri/Cargo.toml.lte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ tauri-build = { version = "1", features = [] }
1616

1717
[dependencies]
1818
tauri = { version = "1", features = ["shell-open"] }{% else %}[build-dependencies]
19-
tauri-build = { version = "2.0.0-beta", features = [] }
19+
tauri-build = { version = "2.0.0-rc", features = [] }
2020

2121
[dependencies]
22-
tauri = { version = "2.0.0-beta", features = [] }
23-
tauri-plugin-shell = "2.0.0-beta"{% endif %}
22+
tauri = { version = "2.0.0-rc", features = [] }
23+
tauri-plugin-shell = "2.0.0-rc"{% endif %}
2424
serde = { version = "1", features = ["derive"] }
2525
serde_json = "1"
2626
{% if stable %}

0 commit comments

Comments
 (0)