Skip to content

Commit d8e65fe

Browse files
authored
fix: always set host to 0.0.0.0 for angular when --rc (#768)
closes #765
1 parent fc0eee9 commit d8e65fe

File tree

5 files changed

+19
-48
lines changed

5 files changed

+19
-48
lines changed

.changes/angluar-template-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": patch
3+
"create-tauri-app-js": patch
4+
---
5+
6+
Fix `--rc` angluar template invalid configuration

src/manifest.rs

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ pub struct Manifest<'a> {
1313
}
1414

1515
impl<'a> Manifest<'a> {
16-
pub fn parse(s: &'a str, mobile: bool) -> Result<Self, anyhow::Error> {
16+
pub fn parse(s: &'a str) -> Result<Self, anyhow::Error> {
1717
let mut manifest = Self::default();
1818

1919
let mut in_files_section = false;
20-
let mut in_mobile_section = false;
2120

2221
for (i, line) in s.split('\n').enumerate() {
2322
let line_number = i + 1;
@@ -31,13 +30,6 @@ impl<'a> Manifest<'a> {
3130

3231
if line == "[files]" {
3332
in_files_section = true;
34-
in_mobile_section = false;
35-
continue;
36-
}
37-
38-
if line == "[mobile]" {
39-
in_mobile_section = true;
40-
in_files_section = false;
4133
continue;
4234
}
4335

@@ -64,16 +56,12 @@ impl<'a> Manifest<'a> {
6456
bail!("parsing manifest: value is empty in line {line_number}");
6557
}
6658

67-
#[allow(clippy::nonminimal_bool)]
68-
let replace =
69-
!in_files_section && (!in_mobile_section || (in_mobile_section && mobile));
70-
7159
match k {
72-
"beforeDevCommand" if replace => manifest.before_dev_command = Some(v),
73-
"beforeBuildCommand" if replace => manifest.before_build_command = Some(v),
74-
"devPath" if replace => manifest.dev_path = Some(v),
75-
"distDir" if replace => manifest.dist_dir = Some(v),
76-
"withGlobalTauri" if replace => manifest.with_global_tauri = Some(v.parse()?),
60+
"beforeDevCommand" => manifest.before_dev_command = Some(v),
61+
"beforeBuildCommand" => manifest.before_build_command = Some(v),
62+
"devPath" => manifest.dev_path = Some(v),
63+
"distDir" => manifest.dist_dir = Some(v),
64+
"withGlobalTauri" => manifest.with_global_tauri = Some(v.parse()?),
7765
_ if in_files_section => {
7866
manifest.files.insert(k, v);
7967
}
@@ -100,15 +88,12 @@ mod test {
10088
beforeBuildCommand = {% pkg_manager_run_command %} build # this comment should be stripped
10189
devPath = http://localhost:1420
10290
103-
[mobile]
104-
beforeBuildCommand = {% pkg_manager_run_command %} build mobile
105-
10691
[files]
10792
tauri.svg = src/assets/tauri.svg
10893
styles.css = src/styles.css
10994
"#;
11095

111-
assert_eq!(Manifest::parse(manifest_file, false).unwrap(), {
96+
assert_eq!(Manifest::parse(manifest_file).unwrap(), {
11297
let mut files = HashMap::new();
11398
files.insert("tauri.svg", "src/assets/tauri.svg");
11499
files.insert("styles.css", "src/styles.css");
@@ -122,21 +107,6 @@ mod test {
122107
files,
123108
}
124109
});
125-
126-
assert_eq!(Manifest::parse(manifest_file, true).unwrap(), {
127-
let mut files = HashMap::new();
128-
files.insert("tauri.svg", "src/assets/tauri.svg");
129-
files.insert("styles.css", "src/styles.css");
130-
131-
Manifest {
132-
before_dev_command: Some("npm start -- --port 1420"),
133-
before_build_command: Some("{% pkg_manager_run_command %} build mobile"),
134-
dev_path: Some("http://localhost:1420"),
135-
dist_dir: None,
136-
with_global_tauri: None,
137-
files,
138-
}
139-
});
140110
}
141111

142112
#[test]
@@ -151,15 +121,12 @@ mod test {
151121
beforeBuildCommand =
152122
devPath = http://localhost:1420
153123
154-
[mobile]
155-
beforeBuildCommand = {% pkg_manager_run_command %} build mobile
156-
157124
[files]
158125
tauri.svg = src/assets/tauri.svg
159126
styles.css = src/styles.css
160127
"#;
161128

162-
Manifest::parse(manifest_file, false).unwrap();
129+
Manifest::parse(manifest_file).unwrap();
163130
}
164131

165132
#[test]
@@ -179,7 +146,7 @@ mod test {
179146
styles.css = src/styles.css
180147
"#;
181148

182-
assert_eq!(Manifest::parse(manifest_file, false).unwrap(), {
149+
assert_eq!(Manifest::parse(manifest_file).unwrap(), {
183150
let mut files = HashMap::new();
184151
files.insert("tauri.svg", "src/assets/tauri.svg");
185152
files.insert("styles.css", "src/styles.css");

src/template.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl<'a> Template {
261261
.data
262262
.to_vec();
263263
let manifest_str = String::from_utf8(manifest_bytes)?;
264-
let manifest = Manifest::parse(&manifest_str, rc)?;
264+
let manifest = Manifest::parse(&manifest_str)?;
265265

266266
let lib_name = format!("{}_lib", package_name.replace('-', "_"));
267267
let project_name_pascal_case = utils::to_pascal_case(project_name);

templates/template-angular/.manifest

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ beforeBuildCommand = {% pkg_manager_run_command %} build
77
devPath = http://localhost:1420
88
distDir = ../dist/{% package_name %}/browser
99

10-
[mobile]
11-
beforeDevCommand = {% pkg_manager_run_command %} start {% double_dash_with_space %}--host $HOST --public-host $HOST
12-
1310
[files]
1411
tauri.svg = src/assets/tauri.svg
1512
styles.css = src/app/app.component.css

templates/template-angular/angular.json.lte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"browser": "src/main.ts",
2121
"polyfills": ["zone.js"],
2222
"tsConfig": "tsconfig.app.json",
23-
"assets": ["src/assets"],
23+
"assets": ["src/assets"]
2424
},
2525
"configurations": {
2626
"production": {
@@ -49,7 +49,8 @@
4949
"serve": {
5050
"builder": "@angular-devkit/build-angular:dev-server",
5151
"options": {
52-
"port": 1420
52+
"port": 1420{% if rc %},
53+
"host": "0.0.0.0"{% endif %}
5354
},
5455
"configurations": {
5556
"production": {

0 commit comments

Comments
 (0)