Implement Syncback to support converting Roblox files to a Rojo project (#937)

This is a very large commit.
Consider checking the linked PR for more information.
This commit is contained in:
Micah
2025-11-19 09:21:33 -08:00
committed by GitHub
parent 071b6e7e23
commit 9b5a07191b
239 changed files with 5325 additions and 225 deletions

View File

@@ -1,5 +1,5 @@
use std::{
collections::{BTreeMap, HashMap, HashSet},
collections::{BTreeMap, HashSet},
ffi::OsStr,
fs, io,
net::IpAddr,
@@ -7,11 +7,13 @@ use std::{
};
use memofs::Vfs;
use rbx_dom_weak::{Ustr, UstrMap};
use rbx_dom_weak::Ustr;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use crate::{glob::Glob, json, resolution::UnresolvedValue, snapshot::SyncRule};
use crate::{
glob::Glob, json, resolution::UnresolvedValue, snapshot::SyncRule, syncback::SyncbackRules,
};
/// Represents 'default' project names that act as `init` files
pub static DEFAULT_PROJECT_NAMES: [&str; 2] = ["default.project.json", "default.project.jsonc"];
@@ -114,6 +116,10 @@ pub struct Project {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub glob_ignore_paths: Vec<Glob>,
/// A list of rules for syncback with this project file.
#[serde(skip_serializing_if = "Option::is_none")]
pub syncback_rules: Option<SyncbackRules>,
/// A list of mappings of globs to syncing rules. If a file matches a glob,
/// it will be 'transformed' into an Instance following the rule provided.
/// Globs are relative to the folder the project file is in.
@@ -332,12 +338,21 @@ pub enum PathNode {
}
impl PathNode {
/// Returns the path of the `PathNode`, without regard for if it's optional
// or not.
#[inline]
pub fn path(&self) -> &Path {
match self {
PathNode::Required(pathbuf) => pathbuf,
PathNode::Optional(OptionalPathNode { optional }) => optional,
}
}
/// Returns whether this `PathNode` is optional or not.
#[inline]
pub fn is_optional(&self) -> bool {
matches!(self, PathNode::Optional(_))
}
}
/// Describes an instance and its descendants in a project.
@@ -367,16 +382,16 @@ pub struct ProjectNode {
#[serde(
rename = "$properties",
default,
skip_serializing_if = "HashMap::is_empty"
skip_serializing_if = "BTreeMap::is_empty"
)]
pub properties: UstrMap<UnresolvedValue>,
pub properties: BTreeMap<Ustr, UnresolvedValue>,
#[serde(
rename = "$attributes",
default,
skip_serializing_if = "HashMap::is_empty"
skip_serializing_if = "BTreeMap::is_empty"
)]
pub attributes: HashMap<String, UnresolvedValue>,
pub attributes: BTreeMap<String, UnresolvedValue>,
/// Defines the behavior when Rojo encounters unknown instances in Roblox
/// Studio during live sync. `$ignoreUnknownInstances` should be considered