From 69f6be1d8961be73f68f38cb3be6d6aae3e8afd2 Mon Sep 17 00:00:00 2001 From: Sasial <44125644+sasial-dev@users.noreply.github.com> Date: Fri, 15 Sep 2023 07:41:56 +1000 Subject: [PATCH] refactor: change scriptType to be emitLegacyScripts --- CHANGELOG.md | 7 ++- .../nested_runcontext/default.project.json | 2 +- .../folder2/default.project.json | 2 +- src/project.rs | 11 +++- src/serve_session.rs | 2 +- src/snapshot/metadata.rs | 24 ++++---- ..._snapshot__tests__apply__add_property.snap | 3 +- ...s__apply__remove_property_after_patch.snap | 3 +- ...tests__apply__remove_property_initial.snap | 3 +- ...tests__apply__set_name_and_class_name.snap | 3 +- ...__snapshot__tests__compute__add_child.snap | 2 +- src/snapshot_middleware/lua.rs | 55 +++++++------------ src/snapshot_middleware/mod.rs | 2 +- src/snapshot_middleware/project.rs | 8 ++- ...t_middleware__csv__test__csv_from_vfs.snap | 2 +- ..._middleware__csv__test__csv_with_meta.snap | 2 +- ...t_middleware__dir__test__empty_folder.snap | 2 +- ...ddleware__dir__test__folder_in_folder.snap | 4 +- ...leware__json__test__instance_from_vfs.snap | 2 +- ...are__json_model__test__model_from_vfs.snap | 4 +- ...on_model__test__model_from_vfs_legacy.snap | 4 +- ...are__lua__test__class_client_from_vfs.snap | 2 +- ...are__lua__test__class_module_from_vfs.snap | 2 +- ...re__lua__test__class_module_with_meta.snap | 2 +- ...are__lua__test__class_script_disabled.snap | 2 +- ...re__lua__test__class_script_with_meta.snap | 2 +- ...are__lua__test__class_server_from_vfs.snap | 2 +- ...lua__test__runcontext_client_from_vfs.snap | 2 +- ...lua__test__runcontext_module_from_vfs.snap | 2 +- ...ua__test__runcontext_module_with_meta.snap | 2 +- ...lua__test__runcontext_script_disabled.snap | 2 +- ...ua__test__runcontext_script_with_meta.snap | 2 +- ...lua__test__runcontext_server_from_vfs.snap | 2 +- ...oject__test__project_from_direct_file.snap | 2 +- ...test__project_path_property_overrides.snap | 2 +- ..._project__test__project_with_children.snap | 4 +- ...t__test__project_with_path_to_project.snap | 2 +- ...ct_with_path_to_project_with_children.snap | 4 +- ...oject__test__project_with_path_to_txt.snap | 2 +- ...est__project_with_resolved_properties.snap | 2 +- ...t__project_with_unresolved_properties.snap | 2 +- ...leware__toml__test__instance_from_vfs.snap | 2 +- ...dleware__txt__test__instance_from_vfs.snap | 2 +- src/snapshot_middleware/util.rs | 5 ++ 44 files changed, 104 insertions(+), 96 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5542c98d3..b60b72e35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,10 +25,15 @@ * Added rich Source diffs in patch visualizer ([#748]) * Fix PatchTree performance issues ([#755]) * Don't override the initial enabled state for source diffing ([#760]) -* A `$scriptType` field has been added to the project.json schema, allowing for scripts to be differentiated through classes or RunContext ([#765]). * Added support for `Terrain.MaterialColors` ([#770]) * Allow `Terrain` to be specified without a classname ([#771]) * Add Confirmation Behavior setting ([#774]) +* Added the `emitLegacyScripts` field to the project format ([#765]). Right now, it defaults to `true`: + +| `$emitLegacyScripts` Value | Action Taken by Rojo | +|----------------------------|------------------------------------------------------------------------------------------------------------------| +| false | Rojo emits Scripts with the appropriate `RunContext` for `*.client.lua` and `*.server.lua` files in the project. | +| true (current default) | Rojo emits LocalScripts and Scripts with legacy Runcontext (same behavior as previously). | [#761]: https://github.com/rojo-rbx/rojo/pull/761 [#745]: https://github.com/rojo-rbx/rojo/pull/745 diff --git a/rojo-test/build-tests/nested_runcontext/default.project.json b/rojo-test/build-tests/nested_runcontext/default.project.json index f05549029..5327be9a8 100644 --- a/rojo-test/build-tests/nested_runcontext/default.project.json +++ b/rojo-test/build-tests/nested_runcontext/default.project.json @@ -1,6 +1,6 @@ { "name": "nested_runcontext", - "scriptType": "RunContext", + "emitLegacyScripts": false, "tree": { "$className": "Folder", "folder1": { diff --git a/rojo-test/build-tests/nested_runcontext/folder2/default.project.json b/rojo-test/build-tests/nested_runcontext/folder2/default.project.json index 9cd652fbf..67feff442 100644 --- a/rojo-test/build-tests/nested_runcontext/folder2/default.project.json +++ b/rojo-test/build-tests/nested_runcontext/folder2/default.project.json @@ -1,6 +1,6 @@ { "name": "nested_runcontext", - "scriptType": "Class", + "emitLegacyScripts": true, "tree": { "$path": "folder3" } diff --git a/src/project.rs b/src/project.rs index bcd123c14..15afa8448 100644 --- a/src/project.rs +++ b/src/project.rs @@ -8,7 +8,9 @@ use std::{ use serde::{Deserialize, Serialize}; use thiserror::Error; -use crate::{glob::Glob, resolution::UnresolvedValue, snapshot_middleware::ScriptContextType}; +use crate::{ + glob::Glob, resolution::UnresolvedValue, snapshot_middleware::emit_legacy_scripts_default, +}; static PROJECT_FILENAME: &str = "default.project.json"; @@ -76,8 +78,11 @@ pub struct Project { /// The mode to use when mapping scripts into Roblox. /// Can be either `Class` or `RunContext` and determines whether script /// behavior is set using the `RunContext` property or the script's `ClassName`. - #[serde(default, skip_serializing_if = "Option::is_none")] - pub script_type: Option, + #[serde( + default = "emit_legacy_scripts_default", + skip_serializing_if = "Option::is_none" + )] + pub emit_legacy_scripts: Option, /// A list of globs, relative to the folder the project file is in, that /// match files that should be excluded if Rojo encounters them. diff --git a/src/serve_session.rs b/src/serve_session.rs index 4f0b7b6df..6f51f0a6f 100644 --- a/src/serve_session.rs +++ b/src/serve_session.rs @@ -123,7 +123,7 @@ impl ServeSession { let root_id = tree.get_root_id(); - let instance_context = InstanceContext::from(root_project.script_type); + let instance_context = InstanceContext::from(root_project.emit_legacy_scripts); log::trace!("Generating snapshot of instances from VFS"); let snapshot = snapshot_from_vfs(&instance_context, &vfs, start_path)?; diff --git a/src/snapshot/metadata.rs b/src/snapshot/metadata.rs index 83fd6e9ac..295735ef6 100644 --- a/src/snapshot/metadata.rs +++ b/src/snapshot/metadata.rs @@ -7,7 +7,8 @@ use std::{ use serde::{Deserialize, Serialize}; use crate::{ - glob::Glob, path_serializer, project::ProjectNode, snapshot_middleware::ScriptContextType, + glob::Glob, path_serializer, project::ProjectNode, + snapshot_middleware::emit_legacy_scripts_default, }; /// Rojo-specific metadata that can be associated with an instance or a snapshot @@ -105,14 +106,14 @@ impl Default for InstanceMetadata { pub struct InstanceContext { #[serde(skip_serializing_if = "Vec::is_empty")] pub path_ignore_rules: Arc>, - pub script_type: ScriptContextType, + pub emit_legacy_scripts: bool, } impl InstanceContext { pub fn new() -> Self { Self { path_ignore_rules: Arc::new(Vec::new()), - script_type: ScriptContextType::Class, + emit_legacy_scripts: emit_legacy_scripts_default().unwrap(), } } @@ -134,26 +135,27 @@ impl InstanceContext { rules.extend(new_rules); } - pub fn set_script_type(&mut self, script_type: ScriptContextType) { - self.script_type = script_type + pub fn set_emit_legacy_scripts(&mut self, emit_legacy_scripts: bool) { + self.emit_legacy_scripts = emit_legacy_scripts } } // serve_session always passes an option from the config file, but tests want it to be explict #[cfg(test)] -impl From for InstanceContext { - fn from(script_type: ScriptContextType) -> Self { +impl From for InstanceContext { + fn from(emit_legacy_scripts: bool) -> Self { Self { - script_type, + emit_legacy_scripts, ..Self::new() } } } -impl From> for InstanceContext { - fn from(script_type: Option) -> Self { +impl From> for InstanceContext { + fn from(emit_legacy_scripts: Option) -> Self { Self { - script_type: script_type.unwrap_or_default(), + emit_legacy_scripts: emit_legacy_scripts + .unwrap_or_else(|| emit_legacy_scripts_default().unwrap()), ..Self::new() } } diff --git a/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__add_property.snap b/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__add_property.snap index 288705b7b..0d594dbc0 100644 --- a/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__add_property.snap +++ b/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__add_property.snap @@ -1,7 +1,6 @@ --- source: src/snapshot/tests/apply.rs expression: tree_view - --- id: id-1 name: ROOT @@ -13,6 +12,6 @@ metadata: ignore_unknown_instances: false relevant_paths: [] context: - script_type: Class + emit_legacy_scripts: true children: [] diff --git a/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__remove_property_after_patch.snap b/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__remove_property_after_patch.snap index 6fe548bc3..b6fcbbd08 100644 --- a/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__remove_property_after_patch.snap +++ b/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__remove_property_after_patch.snap @@ -10,5 +10,6 @@ metadata: ignore_unknown_instances: false relevant_paths: [] context: - script_type: Class + emit_legacy_scripts: true children: [] + diff --git a/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__remove_property_initial.snap b/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__remove_property_initial.snap index 4e6989cee..84b3c3d1e 100644 --- a/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__remove_property_initial.snap +++ b/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__remove_property_initial.snap @@ -1,7 +1,6 @@ --- source: src/snapshot/tests/apply.rs expression: tree_view - --- id: id-1 name: ROOT @@ -13,6 +12,6 @@ metadata: ignore_unknown_instances: false relevant_paths: [] context: - script_type: Class + emit_legacy_scripts: true children: [] diff --git a/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__set_name_and_class_name.snap b/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__set_name_and_class_name.snap index d2c96c9da..325c86f3c 100644 --- a/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__set_name_and_class_name.snap +++ b/src/snapshot/tests/snapshots/librojo__snapshot__tests__apply__set_name_and_class_name.snap @@ -10,5 +10,6 @@ metadata: ignore_unknown_instances: false relevant_paths: [] context: - script_type: Class + emit_legacy_scripts: true children: [] + diff --git a/src/snapshot/tests/snapshots/librojo__snapshot__tests__compute__add_child.snap b/src/snapshot/tests/snapshots/librojo__snapshot__tests__compute__add_child.snap index 82389218d..94ddf12fb 100644 --- a/src/snapshot/tests/snapshots/librojo__snapshot__tests__compute__add_child.snap +++ b/src/snapshot/tests/snapshots/librojo__snapshot__tests__compute__add_child.snap @@ -11,7 +11,7 @@ added_instances: ignore_unknown_instances: false relevant_paths: [] context: - script_type: Class + emit_legacy_scripts: true name: New class_name: Folder properties: {} diff --git a/src/snapshot_middleware/lua.rs b/src/snapshot_middleware/lua.rs index dbe67d89e..c99b4837e 100644 --- a/src/snapshot_middleware/lua.rs +++ b/src/snapshot_middleware/lua.rs @@ -3,7 +3,6 @@ use std::{collections::HashMap, path::Path, str}; use anyhow::Context; use memofs::{IoResultExt, Vfs}; use rbx_dom_weak::types::Enum; -use serde::{Deserialize, Serialize}; use crate::snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot}; @@ -13,13 +12,6 @@ use super::{ util::match_trailing, }; -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Default)] -pub enum ScriptContextType { - #[default] - Class, - RunContext, -} - #[derive(Debug)] enum ScriptType { Server, @@ -58,13 +50,11 @@ pub fn snapshot_lua( return Ok(None); }; - let is_run_context_enabled = context.script_type == ScriptContextType::RunContext; - - let (class_name, run_context) = match (is_run_context_enabled, script_type) { - (true, ScriptType::Server) => ("Script", run_context_enums.get("Server")), - (true, ScriptType::Client) => ("Script", run_context_enums.get("Client")), - (false, ScriptType::Server) => ("Script", run_context_enums.get("Legacy")), - (false, ScriptType::Client) => ("LocalScript", None), + 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), }; @@ -158,7 +148,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::Class), + &InstanceContext::from(true), &mut vfs, Path::new("/foo.lua"), ) @@ -179,7 +169,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::RunContext), + &InstanceContext::from(false), &mut vfs, Path::new("/foo.lua"), ) @@ -200,7 +190,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::Class), + &InstanceContext::from(true), &mut vfs, Path::new("/foo.server.lua"), ) @@ -221,7 +211,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::RunContext), + &InstanceContext::from(false), &mut vfs, Path::new("/foo.server.lua"), ) @@ -242,7 +232,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::Class), + &InstanceContext::from(true), &mut vfs, Path::new("/foo.client.lua"), ) @@ -263,7 +253,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::RunContext), + &InstanceContext::from(false), &mut vfs, Path::new("/foo.client.lua"), ) @@ -289,13 +279,10 @@ mod test { let mut vfs = Vfs::new(imfs); - let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::Class), - &mut vfs, - Path::new("/root"), - ) - .unwrap() - .unwrap(); + let instance_snapshot = + snapshot_lua(&InstanceContext::from(true), &mut vfs, Path::new("/root")) + .unwrap() + .unwrap(); insta::with_settings!({ sort_maps => true }, { insta::assert_yaml_snapshot!(instance_snapshot); @@ -322,7 +309,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::Class), + &InstanceContext::from(true), &mut vfs, Path::new("/foo.lua"), ) @@ -354,7 +341,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::RunContext), + &InstanceContext::from(false), &mut vfs, Path::new("/foo.lua"), ) @@ -386,7 +373,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::Class), + &InstanceContext::from(true), &mut vfs, Path::new("/foo.server.lua"), ) @@ -418,7 +405,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::RunContext), + &InstanceContext::from(false), &mut vfs, Path::new("/foo.server.lua"), ) @@ -452,7 +439,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::Class), + &InstanceContext::from(true), &mut vfs, Path::new("/bar.server.lua"), ) @@ -486,7 +473,7 @@ mod test { let mut vfs = Vfs::new(imfs); let instance_snapshot = snapshot_lua( - &InstanceContext::from(ScriptContextType::RunContext), + &InstanceContext::from(false), &mut vfs, Path::new("/bar.server.lua"), ) diff --git a/src/snapshot_middleware/mod.rs b/src/snapshot_middleware/mod.rs index cb079cc6c..d8cd39409 100644 --- a/src/snapshot_middleware/mod.rs +++ b/src/snapshot_middleware/mod.rs @@ -38,7 +38,7 @@ use self::{ util::PathExt, }; -pub use self::{lua::ScriptContextType, project::snapshot_project_node}; +pub use self::{project::snapshot_project_node, util::emit_legacy_scripts_default}; /// The main entrypoint to the snapshot function. This function can be pointed /// at any path and will return something if Rojo knows how to deal with it. diff --git a/src/snapshot_middleware/project.rs b/src/snapshot_middleware/project.rs index 3d92bf6b8..9df50c9b2 100644 --- a/src/snapshot_middleware/project.rs +++ b/src/snapshot_middleware/project.rs @@ -12,7 +12,7 @@ use crate::{ }, }; -use super::snapshot_from_vfs; +use super::{emit_legacy_scripts_default, snapshot_from_vfs}; pub fn snapshot_project( context: &InstanceContext, @@ -30,7 +30,11 @@ pub fn snapshot_project( }); context.add_path_ignore_rules(rules); - context.set_script_type(project.script_type.unwrap_or_default()); + context.set_emit_legacy_scripts( + project + .emit_legacy_scripts + .unwrap_or_else(|| emit_legacy_scripts_default().unwrap()), + ); match snapshot_project_node(&context, path, &project.name, &project.tree, vfs, None)? { Some(found_snapshot) => { diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__csv__test__csv_from_vfs.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__csv__test__csv_from_vfs.snap index 379d7881b..50ce53c11 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__csv__test__csv_from_vfs.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__csv__test__csv_from_vfs.snap @@ -11,7 +11,7 @@ metadata: - /foo.csv - /foo.meta.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: LocalizationTable properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__csv__test__csv_with_meta.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__csv__test__csv_with_meta.snap index bceaf9a43..c91924f8c 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__csv__test__csv_with_meta.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__csv__test__csv_with_meta.snap @@ -11,7 +11,7 @@ metadata: - /foo.csv - /foo.meta.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: LocalizationTable properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__empty_folder.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__empty_folder.snap index f2469410d..4c0dcbbf4 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__empty_folder.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__empty_folder.snap @@ -18,7 +18,7 @@ metadata: - /foo/init.client.luau - /foo/init.csv context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: Folder properties: {} diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__folder_in_folder.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__folder_in_folder.snap index a596ebe81..6238fe68f 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__folder_in_folder.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__folder_in_folder.snap @@ -18,7 +18,7 @@ metadata: - /foo/init.client.luau - /foo/init.csv context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: Folder properties: {} @@ -39,7 +39,7 @@ children: - /foo/Child/init.client.luau - /foo/Child/init.csv context: - script_type: Class + emit_legacy_scripts: true name: Child class_name: Folder properties: {} diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json__test__instance_from_vfs.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json__test__instance_from_vfs.snap index 0cd2265f4..9cc320ebb 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json__test__instance_from_vfs.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json__test__instance_from_vfs.snap @@ -11,7 +11,7 @@ metadata: - /foo.json - /foo.meta.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: ModuleScript properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json_model__test__model_from_vfs.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json_model__test__model_from_vfs.snap index 754acf3f3..e3ee581e0 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json_model__test__model_from_vfs.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json_model__test__model_from_vfs.snap @@ -10,7 +10,7 @@ metadata: relevant_paths: - /foo.model.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: IntValue properties: @@ -22,7 +22,7 @@ children: ignore_unknown_instances: false relevant_paths: [] context: - script_type: Class + emit_legacy_scripts: true name: The Child class_name: StringValue properties: {} diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json_model__test__model_from_vfs_legacy.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json_model__test__model_from_vfs_legacy.snap index 754acf3f3..e3ee581e0 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json_model__test__model_from_vfs_legacy.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__json_model__test__model_from_vfs_legacy.snap @@ -10,7 +10,7 @@ metadata: relevant_paths: - /foo.model.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: IntValue properties: @@ -22,7 +22,7 @@ children: ignore_unknown_instances: false relevant_paths: [] context: - script_type: Class + emit_legacy_scripts: true name: The Child class_name: StringValue properties: {} diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_client_from_vfs.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_client_from_vfs.snap index 763c638c6..5f5f6e9a1 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_client_from_vfs.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_client_from_vfs.snap @@ -11,7 +11,7 @@ metadata: - /foo.client.lua - /foo.meta.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: LocalScript properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_module_from_vfs.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_module_from_vfs.snap index e59bcda3c..de2471b9a 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_module_from_vfs.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_module_from_vfs.snap @@ -11,7 +11,7 @@ metadata: - /foo.lua - /foo.meta.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: ModuleScript properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_module_with_meta.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_module_with_meta.snap index e244cf2b2..32d70c708 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_module_with_meta.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_module_with_meta.snap @@ -11,7 +11,7 @@ metadata: - /foo.lua - /foo.meta.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: ModuleScript properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_script_disabled.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_script_disabled.snap index 0717f0960..2c5546a53 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_script_disabled.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_script_disabled.snap @@ -11,7 +11,7 @@ metadata: - /bar.server.lua - /bar.meta.json context: - script_type: Class + emit_legacy_scripts: true name: bar class_name: Script properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_script_with_meta.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_script_with_meta.snap index 14ba97be1..e4e31ff96 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_script_with_meta.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_script_with_meta.snap @@ -11,7 +11,7 @@ metadata: - /foo.server.lua - /foo.meta.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: Script properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_server_from_vfs.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_server_from_vfs.snap index 77e1eac47..b70b9cc2b 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_server_from_vfs.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__class_server_from_vfs.snap @@ -11,7 +11,7 @@ metadata: - /foo.server.lua - /foo.meta.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: Script properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_client_from_vfs.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_client_from_vfs.snap index e1873aa8f..6ad72d084 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_client_from_vfs.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_client_from_vfs.snap @@ -11,7 +11,7 @@ metadata: - /foo.client.lua - /foo.meta.json context: - script_type: RunContext + emit_legacy_scripts: false name: foo class_name: Script properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_module_from_vfs.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_module_from_vfs.snap index 1c8fb22bc..83be811be 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_module_from_vfs.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_module_from_vfs.snap @@ -11,7 +11,7 @@ metadata: - /foo.lua - /foo.meta.json context: - script_type: RunContext + emit_legacy_scripts: false name: foo class_name: ModuleScript properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_module_with_meta.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_module_with_meta.snap index e5b7e36d7..98a88ec7f 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_module_with_meta.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_module_with_meta.snap @@ -11,7 +11,7 @@ metadata: - /foo.lua - /foo.meta.json context: - script_type: RunContext + emit_legacy_scripts: false name: foo class_name: ModuleScript properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_script_disabled.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_script_disabled.snap index 38f8ab7b4..c47b83dc3 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_script_disabled.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_script_disabled.snap @@ -11,7 +11,7 @@ metadata: - /bar.server.lua - /bar.meta.json context: - script_type: RunContext + emit_legacy_scripts: false name: bar class_name: Script properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_script_with_meta.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_script_with_meta.snap index 0e0f27520..72d24206f 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_script_with_meta.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_script_with_meta.snap @@ -11,7 +11,7 @@ metadata: - /foo.server.lua - /foo.meta.json context: - script_type: RunContext + emit_legacy_scripts: false name: foo class_name: Script properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_server_from_vfs.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_server_from_vfs.snap index 9bdf4e055..2b902f964 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_server_from_vfs.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__lua__test__runcontext_server_from_vfs.snap @@ -11,7 +11,7 @@ metadata: - /foo.server.lua - /foo.meta.json context: - script_type: RunContext + emit_legacy_scripts: false name: foo class_name: Script properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_from_direct_file.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_from_direct_file.snap index a2bc5ec8a..bd5db23db 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_from_direct_file.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_from_direct_file.snap @@ -10,7 +10,7 @@ metadata: relevant_paths: - /foo/hello.project.json context: - script_type: Class + emit_legacy_scripts: true name: direct-project class_name: Model properties: {} diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_path_property_overrides.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_path_property_overrides.snap index f5df1efe1..77cb44c96 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_path_property_overrides.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_path_property_overrides.snap @@ -11,7 +11,7 @@ metadata: - /foo/other.project.json - /foo/default.project.json context: - script_type: Class + emit_legacy_scripts: true name: path-property-override class_name: StringValue properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_children.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_children.snap index da1431671..914a2f95e 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_children.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_children.snap @@ -10,7 +10,7 @@ metadata: relevant_paths: - /foo.project.json context: - script_type: Class + emit_legacy_scripts: true name: children class_name: Folder properties: {} @@ -26,7 +26,7 @@ children: - Folder relevant_paths: [] context: - script_type: Class + emit_legacy_scripts: true name: Child class_name: Model properties: {} diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_project.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_project.snap index bb2a10d09..02e6ee0ba 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_project.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_project.snap @@ -11,7 +11,7 @@ metadata: - /foo/other.project.json - /foo/default.project.json context: - script_type: Class + emit_legacy_scripts: true name: path-project class_name: Model properties: {} diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_project_with_children.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_project_with_children.snap index a5f6dcb26..baf643653 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_project_with_children.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_project_with_children.snap @@ -11,7 +11,7 @@ metadata: - /foo/other.project.json - /foo/default.project.json context: - script_type: Class + emit_legacy_scripts: true name: path-child-project class_name: Folder properties: {} @@ -27,7 +27,7 @@ children: - Folder relevant_paths: [] context: - script_type: Class + emit_legacy_scripts: true name: SomeChild class_name: Model properties: {} diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_txt.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_txt.snap index b0fb9b09a..223c366cd 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_txt.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_path_to_txt.snap @@ -12,7 +12,7 @@ metadata: - /foo/other.meta.json - /foo/default.project.json context: - script_type: Class + emit_legacy_scripts: true name: path-project class_name: StringValue properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_resolved_properties.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_resolved_properties.snap index b03dbc514..eddb4e040 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_resolved_properties.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_resolved_properties.snap @@ -10,7 +10,7 @@ metadata: relevant_paths: - /foo.project.json context: - script_type: Class + emit_legacy_scripts: true name: resolved-properties class_name: StringValue properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_unresolved_properties.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_unresolved_properties.snap index 7a8f3b225..8bd6e28b8 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_unresolved_properties.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__project__test__project_with_unresolved_properties.snap @@ -10,7 +10,7 @@ metadata: relevant_paths: - /foo.project.json context: - script_type: Class + emit_legacy_scripts: true name: unresolved-properties class_name: StringValue properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__toml__test__instance_from_vfs.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__toml__test__instance_from_vfs.snap index 32f9b8a9b..329bdbcd3 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__toml__test__instance_from_vfs.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__toml__test__instance_from_vfs.snap @@ -11,7 +11,7 @@ metadata: - /foo.toml - /foo.meta.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: ModuleScript properties: diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__txt__test__instance_from_vfs.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__txt__test__instance_from_vfs.snap index 0c5b88b5d..aa3e0f067 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__txt__test__instance_from_vfs.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__txt__test__instance_from_vfs.snap @@ -11,7 +11,7 @@ metadata: - /foo.txt - /foo.meta.json context: - script_type: Class + emit_legacy_scripts: true name: foo class_name: StringValue properties: diff --git a/src/snapshot_middleware/util.rs b/src/snapshot_middleware/util.rs index 16648eae9..625910b77 100644 --- a/src/snapshot_middleware/util.rs +++ b/src/snapshot_middleware/util.rs @@ -41,3 +41,8 @@ where .with_context(|| format!("Path did not end in {}: {}", suffix, path.display())) } } + +// TEMP function until rojo 8.0, when it can be replaced with bool::default (aka false) +pub fn emit_legacy_scripts_default() -> Option { + Some(true) +}