From c791394572e7d0ca9840f65154df2b040a9cef3f Mon Sep 17 00:00:00 2001 From: nezuo Date: Mon, 6 May 2024 20:19:48 -0700 Subject: [PATCH 1/5] Add legacy script sync rule middlewares --- src/snapshot_middleware/lua.rs | 4 ++++ src/snapshot_middleware/mod.rs | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/snapshot_middleware/lua.rs b/src/snapshot_middleware/lua.rs index 3f8d26adf..e498c3a66 100644 --- a/src/snapshot_middleware/lua.rs +++ b/src/snapshot_middleware/lua.rs @@ -15,6 +15,8 @@ pub enum ScriptType { Server, Client, Module, + LegacyServer, + LegacyClient, } /// Core routine for turning Lua files into snapshots. @@ -36,6 +38,8 @@ pub fn snapshot_lua( (false, ScriptType::Client) => ("Script", run_context_enums.get("Client")), (true, ScriptType::Server) => ("Script", run_context_enums.get("Legacy")), (true, ScriptType::Client) => ("LocalScript", None), + (_, ScriptType::LegacyServer) => ("Script", run_context_enums.get("Legacy")), + (_, ScriptType::LegacyClient) => ("LocalScript", None), (_, ScriptType::Module) => ("ModuleScript", None), }; diff --git a/src/snapshot_middleware/mod.rs b/src/snapshot_middleware/mod.rs index 1c95154ef..7af51ff4f 100644 --- a/src/snapshot_middleware/mod.rs +++ b/src/snapshot_middleware/mod.rs @@ -199,6 +199,8 @@ pub enum Middleware { ServerScript, ClientScript, ModuleScript, + LegacyServerScript, + LegacyClientScript, Project, Rbxm, Rbxmx, @@ -224,6 +226,12 @@ impl Middleware { Self::ServerScript => snapshot_lua(context, vfs, path, name, ScriptType::Server), Self::ClientScript => snapshot_lua(context, vfs, path, name, ScriptType::Client), Self::ModuleScript => snapshot_lua(context, vfs, path, name, ScriptType::Module), + Self::LegacyClientScript => { + snapshot_lua(context, vfs, path, name, ScriptType::LegacyClient) + } + Self::LegacyServerScript => { + snapshot_lua(context, vfs, path, name, ScriptType::LegacyServer) + } Self::Project => snapshot_project(context, vfs, path, name), Self::Rbxm => snapshot_rbxm(context, vfs, path, name), Self::Rbxmx => snapshot_rbxmx(context, vfs, path, name), From 1215bc28bb276cc9ee12181b80ece59536a33cb8 Mon Sep 17 00:00:00 2001 From: nezuo Date: Mon, 6 May 2024 20:27:36 -0700 Subject: [PATCH 2/5] Update changelog --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df29083f8..bf1e27c1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * Updated Theme to use Studio colors ([#838]) * Improved patch visualizer UX ([#883]) * Added experimental setting for Auto Connect in playtests ([#840]) -* Projects may now specify rules for syncing files as if they had a different file extension. ([#813]) +* Projects may now specify rules for syncing files as if they had a different file extension. ([#813], [#909]) This is specified via a new field on project files, `syncRules`: ```json @@ -52,6 +52,8 @@ | `project` | `.project.json` | | `ignore` | None! | + Additionaly, regardless of your `emitLegacyScripts` setting, the `legacyServerScript` `use` value will become a Script with Legacy RunContext, and `legacyClientScript` will become a LocalScript. + **All** sync rules are reset between project files, so they must be specified in each one when nesting them. This is to ensure that nothing can break other projects by changing how files are synced! [#813]: https://github.com/rojo-rbx/rojo/pull/813 @@ -61,6 +63,7 @@ [#883]: https://github.com/rojo-rbx/rojo/pull/883 [#893]: https://github.com/rojo-rbx/rojo/pull/893 [#903]: https://github.com/rojo-rbx/rojo/pull/903 +[#909]: https://github.com/rojo-rbx/rojo/pull/909 ## [7.4.1] - February 20, 2024 * Made the `name` field optional on project files ([#870]) From 4a79d17afb03cb55811f332cf888b8131bc01f52 Mon Sep 17 00:00:00 2001 From: nezuo Date: Thu, 9 May 2024 19:59:05 -0700 Subject: [PATCH 3/5] Existing sync rules are now legacy scripts and introduced new run context rules --- src/snapshot_middleware/lua.rs | 18 ++++++++---------- src/snapshot_middleware/mod.rs | 12 ++++++------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/snapshot_middleware/lua.rs b/src/snapshot_middleware/lua.rs index e498c3a66..a046de890 100644 --- a/src/snapshot_middleware/lua.rs +++ b/src/snapshot_middleware/lua.rs @@ -15,8 +15,8 @@ pub enum ScriptType { Server, Client, Module, - LegacyServer, - LegacyClient, + RunContextServer, + RunContextClient, } /// Core routine for turning Lua files into snapshots. @@ -33,14 +33,12 @@ pub fn snapshot_lua( .expect("Unable to get RunContext enums!") .items; - let (class_name, run_context) = match (context.emit_legacy_scripts, script_type) { - (false, ScriptType::Server) => ("Script", run_context_enums.get("Server")), - (false, ScriptType::Client) => ("Script", run_context_enums.get("Client")), - (true, ScriptType::Server) => ("Script", run_context_enums.get("Legacy")), - (true, ScriptType::Client) => ("LocalScript", None), - (_, ScriptType::LegacyServer) => ("Script", run_context_enums.get("Legacy")), - (_, ScriptType::LegacyClient) => ("LocalScript", None), - (_, ScriptType::Module) => ("ModuleScript", None), + let (class_name, run_context) = match script_type { + ScriptType::Server => ("Script", run_context_enums.get("Legacy")), + ScriptType::Client => ("LocalScript", None), + ScriptType::Module => ("ModuleScript", None), + ScriptType::RunContextServer => ("Script", run_context_enums.get("Server")), + ScriptType::RunContextClient => ("Script", run_context_enums.get("Client")), }; let contents = vfs.read_to_string_lf_normalized(path)?; diff --git a/src/snapshot_middleware/mod.rs b/src/snapshot_middleware/mod.rs index 7af51ff4f..de9023ddb 100644 --- a/src/snapshot_middleware/mod.rs +++ b/src/snapshot_middleware/mod.rs @@ -199,8 +199,8 @@ pub enum Middleware { ServerScript, ClientScript, ModuleScript, - LegacyServerScript, - LegacyClientScript, + RunContextServerScript, + RunContextClientScript, Project, Rbxm, Rbxmx, @@ -226,11 +226,11 @@ impl Middleware { Self::ServerScript => snapshot_lua(context, vfs, path, name, ScriptType::Server), Self::ClientScript => snapshot_lua(context, vfs, path, name, ScriptType::Client), Self::ModuleScript => snapshot_lua(context, vfs, path, name, ScriptType::Module), - Self::LegacyClientScript => { - snapshot_lua(context, vfs, path, name, ScriptType::LegacyClient) + Self::RunContextClientScript => { + snapshot_lua(context, vfs, path, name, ScriptType::RunContextClient) } - Self::LegacyServerScript => { - snapshot_lua(context, vfs, path, name, ScriptType::LegacyServer) + Self::RunContextServerScript => { + snapshot_lua(context, vfs, path, name, ScriptType::RunContextServer) } Self::Project => snapshot_project(context, vfs, path, name), Self::Rbxm => snapshot_rbxm(context, vfs, path, name), From db6295a36bba4263c9e9b9e04c1453b72ffe2dfa Mon Sep 17 00:00:00 2001 From: nezuo Date: Mon, 13 May 2024 21:12:41 -0700 Subject: [PATCH 4/5] Introduce legacy script middlewares --- CHANGELOG.md | 11 +++++++++-- src/snapshot_middleware/lua.rs | 20 ++++++++++++++++++-- src/snapshot_middleware/mod.rs | 8 ++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf1e27c1b..3b665fa7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,7 @@ Additionally, the `exclude` field allows files to be excluded from the sync rule if they match a pattern specified by it. If it's not present, all files that match `pattern` will be modified using the sync rule. - The `use` field corresponds to one of the potential file type that Rojo will currently include in a project. Files that match the provided pattern will be treated as if they had the file extension for that file type. A full list is below: + The `use` field corresponds to one of the potential file type that Rojo will currently include in a project. Files that match the provided pattern will be treated as if they had the file extension for that file type. | `use` value | file extension | |:---------------|:----------------| @@ -52,7 +52,14 @@ | `project` | `.project.json` | | `ignore` | None! | - Additionaly, regardless of your `emitLegacyScripts` setting, the `legacyServerScript` `use` value will become a Script with Legacy RunContext, and `legacyClientScript` will become a LocalScript. + Additionally, there are `use` values for specific script types: + + | `use` value | script type | + |:-------------------------|:---------------------------------------| + | `legacyServerScript` | `Script` with `Enum.RunContext.Legacy` | + | `legactClientScript` | `LocalScript` | + | `runContextServerScript` | `Script` with `Enum.RunContext.Server` | + | `runContextClientScript` | `Script` with `Enum.RunContext.Client` | **All** sync rules are reset between project files, so they must be specified in each one when nesting them. This is to ensure that nothing can break other projects by changing how files are synced! diff --git a/src/snapshot_middleware/lua.rs b/src/snapshot_middleware/lua.rs index a046de890..efa0ff6fa 100644 --- a/src/snapshot_middleware/lua.rs +++ b/src/snapshot_middleware/lua.rs @@ -15,6 +15,8 @@ pub enum ScriptType { Server, Client, Module, + LegacyServer, + LegacyClient, RunContextServer, RunContextClient, } @@ -34,9 +36,23 @@ pub fn snapshot_lua( .items; let (class_name, run_context) = match script_type { - ScriptType::Server => ("Script", run_context_enums.get("Legacy")), - ScriptType::Client => ("LocalScript", None), + ScriptType::Server => { + if context.emit_legacy_scripts { + ("Script", None) + } else { + ("Script", run_context_enums.get("Server")) + } + } + ScriptType::Client => { + if context.emit_legacy_scripts { + ("LocalScript", None) + } else { + ("Script", run_context_enums.get("Client")) + } + } ScriptType::Module => ("ModuleScript", None), + ScriptType::LegacyServer => ("Script", run_context_enums.get("Legacy")), + ScriptType::LegacyClient => ("LocalScript", None), ScriptType::RunContextServer => ("Script", run_context_enums.get("Server")), ScriptType::RunContextClient => ("Script", run_context_enums.get("Client")), }; diff --git a/src/snapshot_middleware/mod.rs b/src/snapshot_middleware/mod.rs index de9023ddb..fbfebfae8 100644 --- a/src/snapshot_middleware/mod.rs +++ b/src/snapshot_middleware/mod.rs @@ -199,6 +199,8 @@ pub enum Middleware { ServerScript, ClientScript, ModuleScript, + LegacyClientScript, + LegacyServerScript, RunContextServerScript, RunContextClientScript, Project, @@ -226,6 +228,12 @@ impl Middleware { Self::ServerScript => snapshot_lua(context, vfs, path, name, ScriptType::Server), Self::ClientScript => snapshot_lua(context, vfs, path, name, ScriptType::Client), Self::ModuleScript => snapshot_lua(context, vfs, path, name, ScriptType::Module), + Self::LegacyClientScript => { + snapshot_lua(context, vfs, path, name, ScriptType::LegacyClient) + } + Self::LegacyServerScript => { + snapshot_lua(context, vfs, path, name, ScriptType::LegacyServer) + } Self::RunContextClientScript => { snapshot_lua(context, vfs, path, name, ScriptType::RunContextClient) } From f53d9a5f263e2618f9f83ead3c9dbcb335bd4bca Mon Sep 17 00:00:00 2001 From: nezuo Date: Mon, 13 May 2024 21:19:22 -0700 Subject: [PATCH 5/5] Fix tests --- src/snapshot_middleware/lua.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/snapshot_middleware/lua.rs b/src/snapshot_middleware/lua.rs index efa0ff6fa..c8b3205f0 100644 --- a/src/snapshot_middleware/lua.rs +++ b/src/snapshot_middleware/lua.rs @@ -38,7 +38,7 @@ pub fn snapshot_lua( let (class_name, run_context) = match script_type { ScriptType::Server => { if context.emit_legacy_scripts { - ("Script", None) + ("Script", run_context_enums.get("Legacy")) } else { ("Script", run_context_enums.get("Server")) }