diff --git a/src/builds.rs b/src/builds.rs index 9ba86ca..c109d20 100644 --- a/src/builds.rs +++ b/src/builds.rs @@ -52,6 +52,7 @@ async fn get_temp_credentials( engine: &str, engine_version: &str, entrypoint: Option<&str>, + entrypoint_params: Option, message: Option<&str>, api_key: &str, ) -> Result { @@ -68,11 +69,16 @@ async fn get_temp_credentials( "engineVersion": engine_version }); - // Add entrypoint if provided + // Add entrypoint if provided (for custom engine) if let Some(ep) = entrypoint { request_body["entrypoint"] = serde_json::json!(ep); } + // Add entrypointParams if provided (for JSDOS/Ruffle) + if let Some(ep_params) = entrypoint_params { + request_body["entrypointParams"] = ep_params; + } + // Add build message if provided if let Some(msg) = message { request_body["buildMessage"] = serde_json::json!(msg); @@ -176,6 +182,7 @@ pub async fn handle_build_push(config_path: PathBuf, verbose: bool, message: Opt engine_kind.as_config_key(), wavedash_config.engine_version()?, wavedash_config.entrypoint(), + wavedash_config.executable_entrypoint_params(), message.as_deref(), &api_key, ) diff --git a/src/config.rs b/src/config.rs index 93d1c66..3d11f64 100644 --- a/src/config.rs +++ b/src/config.rs @@ -105,13 +105,15 @@ pub struct CustomSection { #[derive(Debug, Deserialize)] pub struct JsDosSection { pub version: String, - pub entrypoint: String, + pub executable: String, + pub loader_url: Option, } #[derive(Debug, Deserialize)] pub struct RuffleSection { pub version: String, - pub entrypoint: String, + pub executable: String, + pub loader_url: Option, } #[derive(Debug, Deserialize)] @@ -226,7 +228,41 @@ impl WavedashConfig { self.custom .as_ref() .map(|c| c.entrypoint.as_str()) - .or_else(|| self.jsdos.as_ref().map(|j| j.entrypoint.as_str())) - .or_else(|| self.ruffle.as_ref().map(|r| r.entrypoint.as_str())) + } + + /// For JSDOS/Ruffle engines, returns the entrypointParams (executable + optional loader_url) + pub fn executable_entrypoint_params(&self) -> Option { + if let Some(ref jsdos) = self.jsdos { + let mut params = serde_json::json!({ "executable": jsdos.executable }); + if let Some(ref loader_url) = jsdos.loader_url { + params["loaderUrl"] = serde_json::json!(loader_url); + } + Some(params) + } else if let Some(ref ruffle) = self.ruffle { + let mut params = serde_json::json!({ "executable": ruffle.executable }); + if let Some(ref loader_url) = ruffle.loader_url { + params["loaderUrl"] = serde_json::json!(loader_url); + } + Some(params) + } else { + None + } + } + + /// For JSDOS/Ruffle engines, returns all files that must exist in upload_dir + pub fn executable_files_to_validate(&self) -> Vec<&str> { + let mut files = Vec::new(); + if let Some(ref jsdos) = self.jsdos { + files.push(jsdos.executable.as_str()); + if let Some(ref loader_url) = jsdos.loader_url { + files.push(loader_url.as_str()); + } + } else if let Some(ref ruffle) = self.ruffle { + files.push(ruffle.executable.as_str()); + if let Some(ref loader_url) = ruffle.loader_url { + files.push(loader_url.as_str()); + } + } + files } } diff --git a/src/file_staging.rs b/src/file_staging.rs index 3dab468..e79d897 100644 --- a/src/file_staging.rs +++ b/src/file_staging.rs @@ -32,7 +32,7 @@ impl FileStaging { } }; - // Validate entrypoint exists in the upload directory + // Validate entrypoint exists in the upload directory (for custom engine) if let Some(entrypoint_str) = wavedash_config.entrypoint() { let entrypoint_path = upload_dir.join(entrypoint_str); if !entrypoint_path.exists() { @@ -44,6 +44,18 @@ impl FileStaging { } } + // Validate executable and loader_url files exist (for JSDOS/Ruffle) + for file in wavedash_config.executable_files_to_validate() { + let file_path = upload_dir.join(file); + if !file_path.exists() { + anyhow::bail!( + "'{}' not found in upload_dir ({}). The file must exist inside your upload_dir.", + file, + upload_dir.display() + ); + } + } + Ok(Self { config_dest, })