diff --git a/CHANGELOG.md b/CHANGELOG.md index 05550ae26..d2c05902e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ * Added experimental setting for Auto Connect in playtests ([#840]) * Improved settings UI ([#886]) * `Open Scripts Externally` option can now be changed while syncing ([#911]) -* 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 @@ -37,7 +37,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 | |:---------------|:----------------| @@ -54,6 +54,15 @@ | `project` | `.project.json` | | `ignore` | None! | + 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! [#813]: https://github.com/rojo-rbx/rojo/pull/813 @@ -64,6 +73,7 @@ [#886]: https://github.com/rojo-rbx/rojo/pull/886 [#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 [#911]: https://github.com/rojo-rbx/rojo/pull/911 ## [7.4.1] - February 20, 2024 diff --git a/src/snapshot_middleware/lua.rs b/src/snapshot_middleware/lua.rs index 3f8d26adf..c8b3205f0 100644 --- a/src/snapshot_middleware/lua.rs +++ b/src/snapshot_middleware/lua.rs @@ -15,6 +15,10 @@ pub enum ScriptType { Server, Client, Module, + LegacyServer, + LegacyClient, + RunContextServer, + RunContextClient, } /// Core routine for turning Lua files into snapshots. @@ -31,12 +35,26 @@ 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::Module) => ("ModuleScript", None), + let (class_name, run_context) = match script_type { + ScriptType::Server => { + if context.emit_legacy_scripts { + ("Script", run_context_enums.get("Legacy")) + } 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")), }; let contents = vfs.read_to_string_lf_normalized(path)?; diff --git a/src/snapshot_middleware/mod.rs b/src/snapshot_middleware/mod.rs index 1c95154ef..fbfebfae8 100644 --- a/src/snapshot_middleware/mod.rs +++ b/src/snapshot_middleware/mod.rs @@ -199,6 +199,10 @@ pub enum Middleware { ServerScript, ClientScript, ModuleScript, + LegacyClientScript, + LegacyServerScript, + RunContextServerScript, + RunContextClientScript, Project, Rbxm, Rbxmx, @@ -224,6 +228,18 @@ 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) + } + 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), Self::Rbxmx => snapshot_rbxmx(context, vfs, path, name),