Skip to content

Commit d3dbbfc

Browse files
committed
Remove the concept of [custom], just specify entrypoint if not using godot/unity
1 parent 8622a9a commit d3dbbfc

6 files changed

Lines changed: 64 additions & 73 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wavedash"
3-
version = "0.1.64"
3+
version = "0.1.65"
44
edition = "2021"
55
authors = ["Wavedash Team"]
66
description = "Cross-platform CLI tool for uploading game projects to wavedash.com"

src/builds.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ struct TempCredsResponse {
4848

4949
async fn get_temp_credentials(
5050
game_id: &str,
51-
engine: &str,
52-
engine_version: &str,
51+
engine: Option<&str>,
52+
engine_version: Option<&str>,
5353
entrypoint: Option<&str>,
5454
entrypoint_params: Option<serde_json::Value>,
5555
message: Option<&str>,
@@ -65,12 +65,17 @@ async fn get_temp_credentials(
6565
);
6666

6767
let mut request_body = serde_json::json!({
68-
"engine": engine,
69-
"engineVersion": engine_version,
7068
"buildSizeBytes": build_size_bytes
7169
});
7270

73-
// Add entrypoint if provided (for custom engine)
71+
if let Some(eng) = engine {
72+
request_body["engine"] = serde_json::json!(eng);
73+
}
74+
75+
if let Some(ver) = engine_version {
76+
request_body["engineVersion"] = serde_json::json!(ver);
77+
}
78+
7479
if let Some(ep) = entrypoint {
7580
request_body["entrypoint"] = serde_json::json!(ep);
7681
}
@@ -194,8 +199,8 @@ pub async fn handle_build_push(config_path: PathBuf, verbose: bool, message: Opt
194199
let engine_kind = wavedash_config.engine_type()?;
195200
let creds = get_temp_credentials(
196201
&wavedash_config.game_id,
197-
engine_kind.as_config_key(),
198-
wavedash_config.engine_version()?,
202+
engine_kind.map(|e| e.as_label()),
203+
wavedash_config.engine_version(),
199204
wavedash_config.entrypoint(),
200205
wavedash_config.executable_entrypoint_params(),
201206
message.as_deref(),

src/config.rs

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ pub struct UnitySection {
9696
pub version: String,
9797
}
9898

99-
#[derive(Debug, Deserialize)]
100-
pub struct CustomSection {
101-
pub version: String,
102-
pub entrypoint: String,
103-
}
104-
10599
#[derive(Debug, Deserialize)]
106100
pub struct JsDosSection {
107101
pub version: String,
@@ -127,9 +121,6 @@ pub struct WavedashConfig {
127121
#[serde(rename = "unity")]
128122
pub unity: Option<UnitySection>,
129123

130-
#[serde(rename = "custom")]
131-
pub custom: Option<CustomSection>,
132-
133124
#[serde(rename = "jsdos")]
134125
pub jsdos: Option<JsDosSection>,
135126

@@ -141,27 +132,15 @@ pub struct WavedashConfig {
141132
pub enum EngineKind {
142133
Godot,
143134
Unity,
144-
Custom,
145135
JsDos,
146136
Ruffle,
147137
}
148138

149139
impl EngineKind {
150-
pub fn as_config_key(&self) -> &'static str {
151-
match self {
152-
EngineKind::Godot => "godot",
153-
EngineKind::Unity => "unity",
154-
EngineKind::Custom => "custom",
155-
EngineKind::JsDos => "jsdos",
156-
EngineKind::Ruffle => "ruffle",
157-
}
158-
}
159-
160140
pub fn as_label(&self) -> &'static str {
161141
match self {
162142
EngineKind::Godot => "GODOT",
163143
EngineKind::Unity => "UNITY",
164-
EngineKind::Custom => "CUSTOM",
165144
EngineKind::JsDos => "JSDOS",
166145
EngineKind::Ruffle => "RUFFLE",
167146
}
@@ -184,11 +163,10 @@ impl WavedashConfig {
184163
Ok(config)
185164
}
186165

187-
pub fn engine_type(&self) -> Result<EngineKind> {
166+
pub fn engine_type(&self) -> Result<Option<EngineKind>> {
188167
let engines: Vec<EngineKind> = [
189168
self.godot.is_some().then_some(EngineKind::Godot),
190169
self.unity.is_some().then_some(EngineKind::Unity),
191-
self.custom.is_some().then_some(EngineKind::Custom),
192170
self.jsdos.is_some().then_some(EngineKind::JsDos),
193171
self.ruffle.is_some().then_some(EngineKind::Ruffle),
194172
]
@@ -197,36 +175,34 @@ impl WavedashConfig {
197175
.collect();
198176

199177
match engines.len() {
200-
1 => Ok(engines[0]),
201-
0 => anyhow::bail!(
202-
"Config must have exactly one engine section: [godot], [unity], [custom], [jsdos], or [ruffle]"
203-
),
178+
0 => Ok(None),
179+
1 => Ok(Some(engines[0])),
204180
_ => anyhow::bail!(
205-
"Config must have exactly one engine section: [godot], [unity], [custom], [jsdos], or [ruffle]"
181+
"Config must have at most one engine section: [godot], [unity], [jsdos], or [ruffle]"
206182
),
207183
}
208184
}
209185

210-
pub fn engine_version(&self) -> Result<&str> {
186+
pub fn engine_version(&self) -> Option<&str> {
211187
if let Some(ref godot) = self.godot {
212-
Ok(&godot.version)
188+
Some(&godot.version)
213189
} else if let Some(ref unity) = self.unity {
214-
Ok(&unity.version)
215-
} else if let Some(ref custom) = self.custom {
216-
Ok(&custom.version)
190+
Some(&unity.version)
217191
} else if let Some(ref jsdos) = self.jsdos {
218-
Ok(&jsdos.version)
192+
Some(&jsdos.version)
219193
} else if let Some(ref ruffle) = self.ruffle {
220-
Ok(&ruffle.version)
194+
Some(&ruffle.version)
221195
} else {
222-
anyhow::bail!("No engine section found")
196+
None
223197
}
224198
}
225199

200+
/// Returns the entrypoint when no engine block is present (defaults to "index.html").
226201
pub fn entrypoint(&self) -> Option<&str> {
227-
self.custom
228-
.as_ref()
229-
.map(|c| c.entrypoint.as_str())
202+
match self.engine_type() {
203+
Ok(None) => Some("index.html"),
204+
_ => None,
205+
}
230206
}
231207

232208
/// For JSDOS/Ruffle engines, returns the entrypointParams (executable + optional loader_url)

src/dev/mod.rs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ struct CreateLocalBuildResponse {
4242

4343
async fn create_local_build(
4444
game_id: &str,
45-
engine: &str,
46-
engine_version: &str,
45+
engine: Option<&str>,
46+
engine_version: Option<&str>,
4747
entrypoint: Option<&str>,
4848
entrypoint_params: Option<&serde_json::Value>,
4949
api_key: &str,
@@ -56,10 +56,15 @@ async fn create_local_build(
5656
api_host, game_id
5757
);
5858

59-
let mut request_body = serde_json::json!({
60-
"engine": engine,
61-
"engineVersion": engine_version
62-
});
59+
let mut request_body = serde_json::json!({});
60+
61+
if let Some(eng) = engine {
62+
request_body["engine"] = serde_json::json!(eng);
63+
}
64+
65+
if let Some(ver) = engine_version {
66+
request_body["engineVersion"] = serde_json::json!(ver);
67+
}
6368

6469
if let Some(ep) = entrypoint {
6570
request_body["entrypoint"] = serde_json::json!(ep);
@@ -115,36 +120,32 @@ pub async fn handle_dev(config_path: Option<PathBuf>, verbose: bool, no_open: bo
115120
}
116121

117122
let engine_kind = wavedash_config.engine_type()?;
118-
let engine_label = engine_kind.as_label();
119-
120-
let entrypoint = if matches!(engine_kind, EngineKind::Custom) {
121-
Some(
122-
wavedash_config
123-
.entrypoint()
124-
.ok_or_else(|| anyhow::anyhow!("Engine config requires an entrypoint"))?
125-
.to_string(),
126-
)
127-
} else {
128-
None
129-
};
123+
124+
let entrypoint = wavedash_config.entrypoint().map(|s| s.to_string());
130125

131126
// Validate required files exist in upload directory
132127
FileStaging::prepare(&upload_dir, &wavedash_config)?;
133128

134129
let html_entrypoint = locate_html_entrypoint(&upload_dir);
135-
let engine_version = wavedash_config.engine_version()?;
130+
let engine_version = wavedash_config.engine_version();
136131
let entrypoint_params = match engine_kind {
137-
EngineKind::Godot | EngineKind::Unity => {
132+
Some(EngineKind::Godot | EngineKind::Unity) => {
133+
let engine_label = engine_kind.unwrap().as_label();
138134
let html_path = html_entrypoint.as_deref().ok_or_else(|| {
139135
anyhow::anyhow!(
140136
"No HTML file found in upload_dir; required for {} builds",
141137
engine_label
142138
)
143139
})?;
144-
Some(fetch_entrypoint_params(engine_label, engine_version, html_path).await?)
140+
let ver = engine_version.ok_or_else(|| {
141+
anyhow::anyhow!("{} engine requires a version", engine_label)
142+
})?;
143+
Some(fetch_entrypoint_params(engine_label, ver, html_path).await?)
144+
}
145+
Some(EngineKind::JsDos | EngineKind::Ruffle) => {
146+
wavedash_config.executable_entrypoint_params()
145147
}
146-
EngineKind::JsDos | EngineKind::Ruffle => wavedash_config.executable_entrypoint_params(),
147-
EngineKind::Custom => None,
148+
None => None,
148149
};
149150

150151
let (rustls_config, cert_path, _key_path) = load_or_create_certificates().await?;
@@ -168,7 +169,7 @@ pub async fn handle_dev(config_path: Option<PathBuf>, verbose: bool, no_open: bo
168169

169170
let local_build = create_local_build(
170171
&wavedash_config.game_id,
171-
engine_label,
172+
engine_kind.map(|e| e.as_label()),
172173
engine_version,
173174
entrypoint.as_deref(),
174175
entrypoint_params.as_ref(),

src/file_staging.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ impl FileStaging {
1212
upload_dir: &Path,
1313
wavedash_config: &WavedashConfig,
1414
) -> Result<Self> {
15-
// Validate entrypoint exists in the upload directory (for custom engine)
15+
// Validate entrypoint exists and is an HTML file
1616
if let Some(entrypoint_str) = wavedash_config.entrypoint() {
17+
// Entrypoint must be an HTML file
18+
let lower = entrypoint_str.to_ascii_lowercase();
19+
if !lower.ends_with(".html") && !lower.ends_with(".htm") {
20+
anyhow::bail!(
21+
"Entrypoint '{}' must be an HTML file (ending in .html or .htm).",
22+
entrypoint_str,
23+
);
24+
}
25+
1726
let entrypoint_path = upload_dir.join(entrypoint_str);
1827
if !entrypoint_path.exists() {
1928
anyhow::bail!(

0 commit comments

Comments
 (0)