mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 12:45:05 +00:00
Add legacy and runContext script sync rule middlewares (#909)
This commit is contained in:
13
CHANGELOG.md
13
CHANGELOG.md
@@ -64,7 +64,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 |
|
||||
|:---------------|:----------------|
|
||||
@@ -81,6 +81,16 @@
|
||||
| `project` | `.project.json` |
|
||||
| `ignore` | None! |
|
||||
|
||||
Additionally, there are `use` values for specific script types ([#909]):
|
||||
|
||||
| `use` value | script type |
|
||||
|:-------------------------|:---------------------------------------|
|
||||
| `legacyServerScript` | `Script` with `Enum.RunContext.Legacy` |
|
||||
| `legacyClientScript` | `LocalScript` |
|
||||
| `runContextServerScript` | `Script` with `Enum.RunContext.Server` |
|
||||
| `runContextClientScript` | `Script` with `Enum.RunContext.Client` |
|
||||
| `pluginScript` | `Script` with `Enum.RunContext.Plugin` |
|
||||
|
||||
**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
|
||||
@@ -91,6 +101,7 @@
|
||||
[#843]: https://github.com/rojo-rbx/rojo/pull/843
|
||||
[#883]: https://github.com/rojo-rbx/rojo/pull/883
|
||||
[#886]: https://github.com/rojo-rbx/rojo/pull/886
|
||||
[#909]: https://github.com/rojo-rbx/rojo/pull/909
|
||||
[#911]: https://github.com/rojo-rbx/rojo/pull/911
|
||||
[#915]: https://github.com/rojo-rbx/rojo/pull/915
|
||||
[#974]: https://github.com/rojo-rbx/rojo/pull/974
|
||||
|
||||
@@ -16,6 +16,10 @@ pub enum ScriptType {
|
||||
Client,
|
||||
Module,
|
||||
Plugin,
|
||||
LegacyServer,
|
||||
LegacyClient,
|
||||
RunContextServer,
|
||||
RunContextClient,
|
||||
}
|
||||
|
||||
/// Core routine for turning Lua files into snapshots.
|
||||
@@ -32,13 +36,27 @@ 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),
|
||||
(_, ScriptType::Plugin) => ("Script", run_context_enums.get("Plugin")),
|
||||
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::Plugin => ("Script", run_context_enums.get("Plugin")),
|
||||
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)?;
|
||||
|
||||
@@ -203,6 +203,10 @@ pub enum Middleware {
|
||||
ClientScript,
|
||||
ModuleScript,
|
||||
PluginScript,
|
||||
LegacyClientScript,
|
||||
LegacyServerScript,
|
||||
RunContextServerScript,
|
||||
RunContextClientScript,
|
||||
Project,
|
||||
Rbxm,
|
||||
Rbxmx,
|
||||
@@ -229,6 +233,18 @@ impl Middleware {
|
||||
Self::ClientScript => snapshot_lua(context, vfs, path, name, ScriptType::Client),
|
||||
Self::ModuleScript => snapshot_lua(context, vfs, path, name, ScriptType::Module),
|
||||
Self::PluginScript => snapshot_lua(context, vfs, path, name, ScriptType::Plugin),
|
||||
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),
|
||||
|
||||
Reference in New Issue
Block a user