Skip to content

Commit 8b3624b

Browse files
authored
fix: seperate tauri.conf templates for v1 and v2. Fix compatibilies file. Fix --alpha flag not working. (#593)
* fix: seperate tauri.conf templates for v1 and v2. Fix compatibilies file. * fix --alpha flag
1 parent 0c03d32 commit 8b3624b

5 files changed

Lines changed: 63 additions & 13 deletions

File tree

.changes/fix-beta-templates.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
create-tauri-app: patch
3+
create-tauri-app-js: patch
4+
---
5+
6+
Fix tauri v2 beta templates.

src/args.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,23 @@ pub fn parse(argv: Vec<OsString>, bin_name: Option<String>) -> anyhow::Result<Ar
8282
println!("{}", env!("CARGO_PKG_VERSION"));
8383
std::process::exit(0);
8484
}
85-
if pargs.contains("--alpha") {
85+
86+
// pargs.contains() consume the flag so we have to bind the bool to a variable.
87+
let alpha = if pargs.contains("--alpha") {
8688
eprintln!(
8789
"{BOLD}{YELLOW}warning{RESET}: The `{GREEN}--alpha{RESET}` option is now an alias for `{GREEN}--beta{RESET}` and may be removed in the future."
8890
);
89-
}
91+
true
92+
} else {
93+
pargs.contains("--beta")
94+
};
9095

9196
let args = Args {
9297
manager: pargs.opt_value_from_str(["-m", "--manager"])?,
9398
template: pargs.opt_value_from_str(["-t", "--template"])?,
9499
skip: pargs.contains(["-y", "--yes"]),
95100
force: pargs.contains(["-f", "--force"]),
96-
alpha: pargs.contains("--alpha") || pargs.contains("--beta"),
101+
alpha,
97102
mobile: if pargs.contains("--mobile") {
98103
Some(true)
99104
} else {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"productName": "{% project_name %}",
3+
"version": "0.0.0",
4+
"identifier": "com.tauri.dev",
5+
"build": {
6+
"beforeDevCommand": "{% before_dev_command %}",
7+
"beforeBuildCommand": "{% before_build_command %}",
8+
"devUrl": "{% dev_path %}",
9+
"frontendDist": "{% dist_dir %}"
10+
},
11+
"app": {
12+
"security": {
13+
"csp": null
14+
},
15+
"windows": [
16+
{
17+
"fullscreen": false,
18+
"resizable": true,
19+
"title": "{% package_name %}",
20+
"width": 800,
21+
"height": 600
22+
}
23+
]{% if with_global_tauri %},
24+
"withGlobalTauri": true{% endif %}
25+
},
26+
"bundle": {
27+
"active": true,
28+
"targets": "all",
29+
"icon": [
30+
"icons/32x32.png",
31+
"icons/128x128.png",
32+
"icons/128x128@2x.png",
33+
"icons/icon.icns",
34+
"icons/icon.ico"
35+
]
36+
},
37+
"plugins": {
38+
"shell": {
39+
"open": true
40+
}
41+
}
42+
}

templates/_base_/src-tauri/tauri.conf.json.lte renamed to templates/_base_/src-tauri/%(stable)%tauri.conf.json.lte

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
"version": "0.0.0"
1212
},
1313
"tauri": {
14-
{% if stable %}"allowlist": {
14+
"allowlist": {
1515
"all": false,
1616
"shell": {
1717
"all": false,
1818
"open": true
1919
}
2020
},
21-
{% endif %}"bundle": {
21+
"bundle": {
2222
"active": true,
2323
"targets": "all",
2424
"identifier": "com.tauri.dev",
@@ -42,10 +42,5 @@
4242
"height": 600
4343
}
4444
]
45-
}{% if alpha %},
46-
"plugins": {
47-
"shell": {
48-
"open": true
49-
}
50-
}{% endif %}
45+
}
5146
}

templates/_base_/src-tauri/capabilities/main.json renamed to templates/_base_/src-tauri/capabilities/%(alpha)%main.json.lte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"$schema": "./schemas/desktop-schema.json",
33
"identifier": "main-capability",
44
"description": "Capability for the main window",
5-
"windows": ["main"],
5+
"windows": [
6+
"main"
7+
],
68
"permissions": [
79
"path:default",
810
"event:default",
@@ -11,6 +13,6 @@
1113
"resources:default",
1214
"menu:default",
1315
"tray:default",
14-
"shell:open"
16+
"shell:allow-open"
1517
]
1618
}

0 commit comments

Comments
 (0)