mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
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.
This commit is contained in:
parent
5f059dbc16
commit
5a85c5145c
7 changed files with 50 additions and 24 deletions
|
|
@ -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<Option<DirectoryMetada
|
|||
let metadata = DirectoryMetadata::from_slice(&meta_contents, meta_path_json5)?;
|
||||
return Ok(Some(metadata));
|
||||
}
|
||||
|
||||
|
||||
// Legacy fallback: init.meta.json
|
||||
let meta_path_json = path.join("init.meta.json");
|
||||
if let Some(meta_contents) = vfs.read(&meta_path_json).with_not_found()? {
|
||||
let metadata = DirectoryMetadata::from_slice(&meta_contents, meta_path_json)?;
|
||||
return Ok(Some(metadata));
|
||||
}
|
||||
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
|
|
@ -526,7 +526,7 @@ pub fn file_meta(vfs: &Vfs, path: &Path, name: &str) -> anyhow::Result<Option<Ad
|
|||
let metadata = AdjacentMetadata::from_slice(&meta_contents, meta_path_json5)?;
|
||||
return Ok(Some(metadata));
|
||||
}
|
||||
|
||||
|
||||
// Legacy fallback: .meta.json
|
||||
let mut meta_path_json = path.with_file_name(name);
|
||||
meta_path_json.set_extension("meta.json");
|
||||
|
|
@ -534,7 +534,7 @@ pub fn file_meta(vfs: &Vfs, path: &Path, name: &str) -> anyhow::Result<Option<Ad
|
|||
let metadata = AdjacentMetadata::from_slice(&meta_contents, meta_path_json)?;
|
||||
return Ok(Some(metadata));
|
||||
}
|
||||
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,9 +133,11 @@ fn get_dir_middleware<'path>(
|
|||
(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"),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue