mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 20:55:50 +00:00
* Mostly mechanical port bits * Almost there * It builds again! * Turn on all the code again * Tests compiling but not passing * Stub work for value resolution * Implement resolution minus enums and derived properties * Implement property descriptor resolution * Update referent snapshots * Update unions test project Using a place file instead of a model yields better error messages in Roblox Studio. * Add easy shortcut to testing with local rbx-dom * Update rbx-dom * Add enum resolution * Update init.meta.json to use UnresolvedValue * Expand value resolution support, add test * Filter SharedString values from web API * Add 'property' builder method to InstanceSnapshot * Change InstanceSnapshot/InstanceBuilder boundary * Fix remove_file crash * rustfmt * Update to latest rbx_dom_lua * Update dependencies, including rbx_dom_weak * Update to latest rbx-dom * Update dependencies * Update rbx-dom, fixing more bugs * Remove experimental warning on binary place builds * Remove unused imports
71 lines
2.0 KiB
Rust
71 lines
2.0 KiB
Rust
use std::{
|
|
fs::{self, File},
|
|
io::BufWriter,
|
|
};
|
|
|
|
use anyhow::Result;
|
|
use memofs::{InMemoryFs, Vfs, VfsSnapshot};
|
|
use roblox_install::RobloxStudio;
|
|
|
|
use crate::{
|
|
cli::{PluginCommand, PluginSubcommand},
|
|
serve_session::ServeSession,
|
|
};
|
|
|
|
static PLUGIN_BINCODE: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/plugin.bincode"));
|
|
static PLUGIN_FILE_NAME: &str = "RojoManagedPlugin.rbxm";
|
|
|
|
pub fn plugin(options: PluginCommand) -> Result<()> {
|
|
match options.subcommand {
|
|
PluginSubcommand::Install => install_plugin(),
|
|
PluginSubcommand::Uninstall => uninstall_plugin(),
|
|
}
|
|
}
|
|
|
|
pub fn install_plugin() -> Result<()> {
|
|
let plugin_snapshot: VfsSnapshot = bincode::deserialize(PLUGIN_BINCODE)
|
|
.expect("Rojo's plugin was not properly packed into Rojo's binary");
|
|
|
|
let studio = RobloxStudio::locate()?;
|
|
|
|
let plugins_folder_path = studio.plugins_path();
|
|
|
|
if !plugins_folder_path.exists() {
|
|
log::debug!("Creating Roblox Studio plugins folder");
|
|
fs::create_dir(plugins_folder_path)?;
|
|
}
|
|
|
|
let mut in_memory_fs = InMemoryFs::new();
|
|
in_memory_fs.load_snapshot("/plugin", plugin_snapshot)?;
|
|
|
|
let vfs = Vfs::new(in_memory_fs);
|
|
let session = ServeSession::new(vfs, "/plugin")?;
|
|
|
|
let plugin_path = plugins_folder_path.join(PLUGIN_FILE_NAME);
|
|
log::debug!("Writing plugin to {}", plugin_path.display());
|
|
|
|
let mut file = BufWriter::new(File::create(plugin_path)?);
|
|
|
|
let tree = session.tree();
|
|
let root_id = tree.get_root_id();
|
|
|
|
rbx_binary::to_writer_default(&mut file, tree.inner(), &[root_id])?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
fn uninstall_plugin() -> Result<()> {
|
|
let studio = RobloxStudio::locate()?;
|
|
|
|
let plugin_path = studio.plugins_path().join(PLUGIN_FILE_NAME);
|
|
|
|
if plugin_path.exists() {
|
|
log::debug!("Removing existing plugin from {}", plugin_path.display());
|
|
fs::remove_file(plugin_path)?;
|
|
} else {
|
|
log::debug!("Plugin not installed at {}", plugin_path.display());
|
|
}
|
|
|
|
Ok(())
|
|
}
|