Skip to content

Commit c5c0d99

Browse files
authored
refactor: use project_name for tauri.conf.json > productName (#529)
1 parent 3ca02f5 commit c5c0d99

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"create-tauri-app": "patch"
3+
"create-tauri-app-js": "patch"
4+
---
5+
6+
Generate `tauri.conf.json > project > productName` using the "Project name", which can contain spaces and uppercase letters, instead of "Package name".
7+

packages/cli/fragments/_base_/src-tauri/tauri.conf.json.lts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"withGlobalTauri": true{% endif %}
88
},
99
"package": {
10-
"productName": "{% package_name %}",
10+
"productName": "{% project_name %}",
1111
"version": "0.0.0"
1212
},
1313
"tauri": {

packages/cli/src/lib.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ where
8585
}
8686
}
8787

88-
// Project name used for the project directory name
88+
// Project name used for the project directory name and productName in tauri.conf.json
8989
// and if valid, it will also be used in Cargo.toml, Package.json ...etc
9090
let project_name = match project_name {
9191
Some(name) => name,
@@ -123,7 +123,7 @@ where
123123
if is_valid_pkg_name(input) {
124124
Ok(())
125125
} else {
126-
Err("Package name should only include alphanumeric character and hyphens \"-\" and doesn't start with numbers")
126+
Err("Package name should only include lowercase alphanumeric character and hyphens \"-\" and doesn't start with numbers")
127127
}
128128
})
129129
.interact_text()?
@@ -332,7 +332,14 @@ where
332332
}
333333

334334
// Render the template
335-
template.render(&target_dir, pkg_manager, &package_name, alpha, mobile)?;
335+
template.render(
336+
&target_dir,
337+
pkg_manager,
338+
&project_name,
339+
&package_name,
340+
alpha,
341+
mobile,
342+
)?;
336343

337344
// Print post-render instructions
338345
println!();

packages/cli/src/template.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ impl<'a> Template {
222222
&self,
223223
target_dir: &path::Path,
224224
pkg_manager: PackageManager,
225+
project_name: &str,
225226
package_name: &str,
226227
alpha: bool,
227228
mobile: bool,
@@ -252,6 +253,7 @@ impl<'a> Template {
252253
("alpha", alpha.to_string()),
253254
("mobile", mobile.to_string()),
254255
("lib_name", lib_name),
256+
("project_name", project_name.to_string()),
255257
("package_name", package_name.to_string()),
256258
(
257259
"before_dev_command",

0 commit comments

Comments
 (0)