From 69a0f8b7b4b5b11fbbe940513bd5a5d7554dcff5 Mon Sep 17 00:00:00 2001 From: Shae Date: Tue, 5 Sep 2023 23:34:04 -0500 Subject: [PATCH 1/4] rojo-keep and other fixes --- src/cli/syncback.rs | 7 ++--- src/snapshot_middleware/dir.rs | 51 ++++++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/cli/syncback.rs b/src/cli/syncback.rs index acbc4abfe..6382a4b52 100644 --- a/src/cli/syncback.rs +++ b/src/cli/syncback.rs @@ -7,9 +7,9 @@ use std::{ use crate::{ open_tree::{open_tree_at_location, InputTree}, - snapshot::{RojoTree}, + snapshot::RojoTree, }; -use anyhow::{bail}; +use anyhow::bail; use clap::Parser; use memofs::Vfs; @@ -17,9 +17,6 @@ use rbx_dom_weak::WeakDom; use super::resolve_path; -const UNKNOWN_INPUT_KIND_ERR: &str = "Could not detect what kind of file to sync from. \ - Expected output file to end in .rbxl, .rbxlx, .rbxm, or .rbxmx."; - /// Syncs changes back to the filesystem from a model or place file. #[derive(Debug, Parser)] pub struct SyncbackCommand { diff --git a/src/snapshot_middleware/dir.rs b/src/snapshot_middleware/dir.rs index 420aca9fa..8da183c5d 100644 --- a/src/snapshot_middleware/dir.rs +++ b/src/snapshot_middleware/dir.rs @@ -106,6 +106,8 @@ impl SnapshotMiddleware for DirectoryMiddleware { instance: &Instance, consider_descendants: bool, ) -> Option { + let is_preferred_class = preferred_classes().contains(instance.class.as_str()); + // Directory representation is not an option if we have more than one // child with the same name let mut names = HashSet::new(); @@ -113,16 +115,24 @@ impl SnapshotMiddleware for DirectoryMiddleware { let inst = dom.get_by_ref(*child_ref).unwrap(); let name = inst.name.as_str(); if !names.insert(name.to_lowercase()) { - log::info!("Cannot save {} as a directory because it contains 2+ children with the same name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name); + if is_preferred_class && consider_descendants { + log::info!("Cannot save {} as a directory because it contains 2+ children with the same name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name); + } else { + log::debug!("Cannot save {} as a directory because it contains 2+ children with the same name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name); + } return None; } if !is_filename_legal_everywhere(name) { - log::info!("Cannot save {} as a directory because it contains a child with an invalid name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name); + if is_preferred_class && consider_descendants { + log::info!("Cannot save {} as a directory because it contains a child with an invalid name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name); + } else { + log::debug!("Cannot save {} as a directory because it contains a child with an invalid name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name); + } return None; } } - if preferred_classes().contains(instance.class.as_str()) { + if is_preferred_class { if consider_descendants { Some(PRIORITY_MANY_READABLE) } else { @@ -285,6 +295,29 @@ fn syncback_update(sync: &SyncbackArgs<'_, '_>) -> anyhow::Result } } + if new_inst.name == "Vehicles" { + println!( + "DEBUG VEHICLES: {} {} {}", + new_inst.class == "Folder", + fs_snapshot.files.is_empty(), + new_inst.children().is_empty() + ); + println!( + "DEBUG VEHICLES : {} {:?} {}", + new_inst.class, + fs_snapshot.files, + new_inst.children().len() + ); + } + + if new_inst.class == "Folder" { + if fs_snapshot.files.is_empty() && new_inst.children().is_empty() { + fs_snapshot + .files + .insert(path.join(".rojo-keep"), Some(Arc::new(Vec::new()))); + } + } + metadata.fs_snapshot = Some(fs_snapshot); Ok(SyncbackNode::new( @@ -462,6 +495,14 @@ fn syncback_new(sync: &SyncbackArgs<'_, '_>) -> anyhow::Result { } } + if new_inst.class == "Folder" { + if fs_snapshot.files.is_empty() && new_inst.children().is_empty() { + fs_snapshot + .files + .insert(path.join(".rojo-keep"), Some(Arc::new(Vec::new()))); + } + } + metadata.fs_snapshot = Some(fs_snapshot); Ok(SyncbackNode::new( @@ -673,6 +714,10 @@ pub fn snapshot_dir_no_meta( let fs_snapshot = snapshot.metadata.fs_snapshot.as_mut().unwrap(); fs_snapshot.dirs.insert(path.to_path_buf()); + // ensure .rojo-keep is deleted if we syncback and it's not needed anymore. + // it does not matter if it was actually present in the first place. + fs_snapshot.files.insert(path.join(".rojo-keep"), None); + Ok(Some(snapshot)) } From 3dec1b9d3b8867241b209dd5bf13f86c9b015206 Mon Sep 17 00:00:00 2001 From: Shae Date: Tue, 5 Sep 2023 23:34:53 -0500 Subject: [PATCH 2/4] Up version --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- plugin/wally.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 753d5ec54..0a3b208eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1928,7 +1928,7 @@ dependencies = [ [[package]] name = "rojo" -version = "7.3.0-uplift.12.pre.3" +version = "7.3.0-uplift.12.pre.4" dependencies = [ "anyhow", "backtrace", diff --git a/Cargo.toml b/Cargo.toml index 5082b846e..637f05d43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rojo" -version = "7.3.0-uplift.12.pre.3" +version = "7.3.0-uplift.12.pre.4" rust-version = "1.71.0" authors = ["Lucien Greathouse "] description = "Enables professional-grade development tools for Roblox developers" diff --git a/README.md b/README.md index 10739b3e1..530e79b76 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ Rojo can be installed with Aftman, a toolchain manager for Roblox projects: ```toml [tools] -rojo = "UpliftGames/rojo@7.3.0-uplift.12.pre.3" +rojo = "UpliftGames/rojo@7.3.0-uplift.12.pre.4" ``` ### From GitHub Releases diff --git a/plugin/wally.toml b/plugin/wally.toml index b1282a0f6..8b3f5f896 100644 --- a/plugin/wally.toml +++ b/plugin/wally.toml @@ -1,7 +1,7 @@ [package] name = "rojo-rbx/rojo" description = "Rojo enables Roblox developers to use professional-grade software engineering tools" -version = "7.3.0-uplift.12.pre.3" +version = "7.3.0-uplift.12.pre.4" license = "MPL-2.0" authors = ["LPGhatguy (https://lpg.space/)"] registry = "https://github.com/upliftgames/wally-index" From a8b47040f6c98b1bde5d73331a69ea415aacd703 Mon Sep 17 00:00:00 2001 From: Shae Date: Tue, 5 Sep 2023 23:40:16 -0500 Subject: [PATCH 3/4] Remove debug print --- src/snapshot_middleware/dir.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/snapshot_middleware/dir.rs b/src/snapshot_middleware/dir.rs index 8da183c5d..8677ecae6 100644 --- a/src/snapshot_middleware/dir.rs +++ b/src/snapshot_middleware/dir.rs @@ -295,21 +295,6 @@ fn syncback_update(sync: &SyncbackArgs<'_, '_>) -> anyhow::Result } } - if new_inst.name == "Vehicles" { - println!( - "DEBUG VEHICLES: {} {} {}", - new_inst.class == "Folder", - fs_snapshot.files.is_empty(), - new_inst.children().is_empty() - ); - println!( - "DEBUG VEHICLES : {} {:?} {}", - new_inst.class, - fs_snapshot.files, - new_inst.children().len() - ); - } - if new_inst.class == "Folder" { if fs_snapshot.files.is_empty() && new_inst.children().is_empty() { fs_snapshot From 33ffd5a87c6d9da14f89c56f660792c08c9af6b8 Mon Sep 17 00:00:00 2001 From: Shae Date: Thu, 7 Sep 2023 12:46:21 -0700 Subject: [PATCH 4/4] Fix project example name --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 530e79b76..5cf70e140 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Known issues: How to: 1. Prepare your project for assets by adding folders and project file entries for common asset locations like Workspace and ReplicatedStorage 2. Save your place file somewhere accessible -3. Syncback: `rojo syncback --input path/to/your/place.rbxl path/to/your/project.default.json` +3. Syncback: `rojo syncback --input path/to/your/place.rbxl path/to/your/project_name.project.json` 4. Confirm that the diff looks right and it will write the assets to the filesystem Exciting features list: @@ -166,4 +166,4 @@ Pull requests are welcome! Rojo supports Rust 1.58.1 and newer. The minimum supported version of Rust is based on the latest versions of the dependencies that Rojo has. ## License -Rojo is available under the terms of the Mozilla Public License, Version 2.0. See [LICENSE.txt](LICENSE.txt) for details. \ No newline at end of file +Rojo is available under the terms of the Mozilla Public License, Version 2.0. See [LICENSE.txt](LICENSE.txt) for details.