From 5a85c5145c3a85635066d9702f9d83a0b5a6bd45 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 30 Jan 2026 10:06:32 -0600 Subject: [PATCH] Refactor project configuration to use .json format - Replaced the legacy .json5 project file with a new .json format for `plugin.project.json`. - Updated `build.rs` to prioritize the new .json format while maintaining backward compatibility with .json5. - Made adjustments to the Confirming.lua file to enhance UI consistency. - Improved metadata handling in snapshot middleware to support both modern and legacy file extensions. --- build.rs | 13 ++++++++++- plugin.project.json5 => plugin.project.json | 0 plugin/src/App/StatusPages/Confirming.lua | 24 ++++++++++----------- src/snapshot_middleware/meta_file.rs | 10 ++++----- src/snapshot_middleware/mod.rs | 14 ++++++++---- src/syncback/file_names.rs | 4 +++- src/syncback/snapshot.rs | 9 +++++++- 7 files changed, 50 insertions(+), 24 deletions(-) rename plugin.project.json5 => plugin.project.json (100%) diff --git a/build.rs b/build.rs index caec33c5..b5384c72 100644 --- a/build.rs +++ b/build.rs @@ -74,8 +74,19 @@ fn main() -> Result<(), anyhow::Error> { let template_snapshot = snapshot_from_fs_path(&templates_dir)?; + // Try modern .json5 extension first, fall back to legacy .json + let plugin_project_path = { + let json5_path = root_dir.join("plugin.project.json5"); + let json_path = root_dir.join("plugin.project.json"); + if json5_path.exists() { + json5_path + } else { + json_path + } + }; + let plugin_snapshot = VfsSnapshot::dir(hashmap! { - "default.project.json5" => snapshot_from_fs_path(&root_dir.join("plugin.project.json5"))?, + "default.project.json5" => snapshot_from_fs_path(&plugin_project_path)?, "plugin" => VfsSnapshot::dir(hashmap! { "fmt" => snapshot_from_fs_path(&plugin_dir.join("fmt"))?, "http" => snapshot_from_fs_path(&plugin_dir.join("http"))?, diff --git a/plugin.project.json5 b/plugin.project.json similarity index 100% rename from plugin.project.json5 rename to plugin.project.json diff --git a/plugin/src/App/StatusPages/Confirming.lua b/plugin/src/App/StatusPages/Confirming.lua index c166caae..7c4daa40 100644 --- a/plugin/src/App/StatusPages/Confirming.lua +++ b/plugin/src/App/StatusPages/Confirming.lua @@ -327,18 +327,18 @@ function ConfirmingPage:render() self:setState({ showingAcceptConfirm = false }) end, }, { - Content = e("Frame", { - Size = UDim2.fromScale(1, 1), - BackgroundColor3 = theme.Background2, - BorderSizePixel = 0, - }, { - Message = e("TextLabel", { - Text = string.format( - "%d item%s not been reviewed.\n\nAccept selected changes and skip the rest?", - self.state.unselectedCount, - self.state.unselectedCount == 1 and " has" or "s have" - ), - FontFace = theme.Font.Regular, + Content = e("Frame", { + Size = UDim2.fromScale(1, 1), + BackgroundColor3 = theme.BackgroundColor, + BorderSizePixel = 0, + }, { + Message = e("TextLabel", { + Text = string.format( + "%d item%s not been reviewed.\n\nAccept selected changes and skip the rest?", + self.state.unselectedCount, + self.state.unselectedCount == 1 and " has" or "s have" + ), + FontFace = theme.Font.Main, TextSize = theme.TextSize.Body, TextColor3 = theme.TextColor, TextWrapped = true, diff --git a/src/snapshot_middleware/meta_file.rs b/src/snapshot_middleware/meta_file.rs index d69798e0..2f929127 100644 --- a/src/snapshot_middleware/meta_file.rs +++ b/src/snapshot_middleware/meta_file.rs @@ -64,7 +64,7 @@ impl AdjacentMetadata { .or_else(|| file_stem.strip_suffix(".local")) .or_else(|| file_stem.strip_suffix(".legacy")) .unwrap_or(file_stem); - + // Try modern extension first, then fall back to legacy let meta_path_json5 = path.with_file_name(format!("{base_name}.meta.json5")); let meta_path_json = path.with_file_name(format!("{base_name}.meta.json")); @@ -503,14 +503,14 @@ pub fn dir_meta(vfs: &Vfs, path: &Path) -> anyhow::Result anyhow::Result anyhow::Result( (Middleware::LegacyScriptDir, "init.legacy.luau"), (Middleware::CsvDir, "init.csv"), // Legacy extensions (for backwards compatibility) + // init.server.lua → Script with RunContext.Legacy (old emitLegacyScripts behavior) + // init.client.lua → LocalScript (old emitLegacyScripts behavior) (Middleware::ModuleScriptDir, "init.lua"), - (Middleware::ServerScriptDir, "init.server.lua"), - (Middleware::ClientScriptDir, "init.client.lua"), + (Middleware::LegacyScriptDir, "init.server.lua"), + (Middleware::LocalScriptDir, "init.client.lua"), ] }); @@ -431,8 +433,12 @@ pub fn default_sync_rules() -> &'static [SyncRule] { sync_rule!("*.model.json5", JsonModel, ".model.json5"), sync_rule!("*.json5", Json, ".json5", "*.meta.json5"), // Legacy Lua extensions (for backwards compatibility) - sync_rule!("*.server.lua", ServerScript, ".server.lua"), - sync_rule!("*.client.lua", ClientScript, ".client.lua"), + // .server.lua → Script with RunContext.Legacy (old emitLegacyScripts behavior) + // .client.lua → LocalScript (old emitLegacyScripts behavior) + // .plugin.lua → Script with RunContext.Plugin + sync_rule!("*.server.lua", LegacyScript, ".server.lua"), + sync_rule!("*.client.lua", LocalScript, ".client.lua"), + sync_rule!("*.plugin.lua", PluginScript, ".plugin.lua"), sync_rule!("*.lua", ModuleScript), // Legacy JSON extensions (for backwards compatibility) sync_rule!("*.project.json", Project, ".project.json"), diff --git a/src/syncback/file_names.rs b/src/syncback/file_names.rs index 4d1e7351..1e3f5a20 100644 --- a/src/syncback/file_names.rs +++ b/src/syncback/file_names.rs @@ -38,7 +38,9 @@ pub fn name_for_inst<'old>( | Middleware::CsvDir | Middleware::ServerScriptDir | Middleware::ClientScriptDir - | Middleware::ModuleScriptDir => { + | Middleware::ModuleScriptDir + | Middleware::LocalScriptDir + | Middleware::LegacyScriptDir => { let name = if encode_invalid_chars { let encoded = encode_path_name(&new_inst.name); // Validate for issues not fixed by encoding (trailing space/dot, control chars, reserved names) diff --git a/src/syncback/snapshot.rs b/src/syncback/snapshot.rs index b7a0660b..60256dc2 100644 --- a/src/syncback/snapshot.rs +++ b/src/syncback/snapshot.rs @@ -306,7 +306,14 @@ impl<'sync> SyncbackSnapshot<'sync> { pub fn filter_out_property(inst: &Instance, prop_name: &str) -> bool { match inst.class.as_str() { - "Script" | "LocalScript" | "ModuleScript" => { + "Script" => { + // These properties shouldn't be set by scripts that are created via + // `$path` or via being on the file system. + // RunContext is filtered because it's encoded in the file extension: + // .server.luau → Server, .client.luau → Client, .plugin.luau → Plugin, .legacy.luau → Legacy + prop_name == "Source" || prop_name == "ScriptGuid" || prop_name == "RunContext" + } + "LocalScript" | "ModuleScript" => { // These properties shouldn't be set by scripts that are created via // `$path` or via being on the file system. prop_name == "Source" || prop_name == "ScriptGuid"