From 8a2699408426e49d791347520b4b01ec81ef7694 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Mon, 25 Jun 2018 22:10:03 -0700 Subject: [PATCH] Simplify plugin installation by using Plugins instead of InstalledPlugins --- server/src/commands/serve.rs | 2 +- server/src/roblox_studio.rs | 34 +++++++++------------------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/server/src/commands/serve.rs b/server/src/commands/serve.rs index b70261fd..243ee335 100644 --- a/server/src/commands/serve.rs +++ b/server/src/commands/serve.rs @@ -27,7 +27,7 @@ pub fn serve(project_dir: &PathBuf, override_port: Option) { println!("Using project {:#?}", project); - roblox_studio::install_bundled_plugin(); + roblox_studio::install_bundled_plugin().unwrap(); let mut session = Session::new(project.clone()); session.start(); diff --git a/server/src/roblox_studio.rs b/server/src/roblox_studio.rs index a79cb059..ee90a0b5 100644 --- a/server/src/roblox_studio.rs +++ b/server/src/roblox_studio.rs @@ -10,10 +10,7 @@ use std::env; compile_error!("`bundle-plugin` feature must be set for release builds."); #[cfg(feature = "bundle-plugin")] -static PLUGIN_RBXM: &'static [u8] = include_bytes!("../target/plugin.rbxm"); - -const ROJO_HOTSWAP_PLUGIN_ID: &'static str = "0"; -const ROJO_RELEASE_PLUGIN_ID: &'static str = "1997686364"; +static PLUGIN_RBXM: &'static [u8] = include_bytes!("../target/plugin.rbxmx"); #[cfg(target_os = "windows")] pub fn get_install_location() -> Option { @@ -36,43 +33,30 @@ pub fn get_install_location() -> Option { None } -#[cfg(feature = "bundle-plugin")] pub fn get_plugin_location() -> Option { let mut location = get_install_location()?; - location.push("InstalledPlugins"); - location.push(ROJO_RELEASE_PLUGIN_ID); - - Some(location) -} - -#[cfg(not(feature = "bundle-plugin"))] -pub fn get_plugin_location() -> Option { - let mut location = get_install_location()?; - - location.push("InstalledPlugins"); - location.push(ROJO_HOTSWAP_PLUGIN_ID); + location.push("Plugins/Rojo.rbxmx"); Some(location) } #[cfg(feature = "bundle-plugin")] pub fn install_bundled_plugin() -> Option<()> { - use std::fs::create_dir_all; + use std::fs::File; + use std::io::Write; println!("Installing plugin..."); - // TODO: Check error of this value; the only one we actually want to ignore - // is ErrorKind::AlreadyExists probably. - let _ = create_dir_all(get_plugin_location()?); - - // TODO: Copy PLUGIN_RBXM to plugin_location/Plugin.rbxm - // TODO: Update PluginMetadata.json + let mut file = File::create(get_plugin_location()?).ok()?; + file.write_all(PLUGIN_RBXM).ok()?; Some(()) } #[cfg(not(feature = "bundle-plugin"))] -pub fn install_bundled_plugin() { +pub fn install_bundled_plugin() -> Option<()> { println!("Skipping plugin installation, bundle-plugin not set."); + + Some(()) } \ No newline at end of file