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
13
build.rs
13
build.rs
|
|
@ -74,8 +74,19 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
|
|
||||||
let template_snapshot = snapshot_from_fs_path(&templates_dir)?;
|
let template_snapshot = snapshot_from_fs_path(&templates_dir)?;
|
||||||
|
|
||||||
|
// Try modern .json5 extension first, fall back to legacy .json
|
||||||
|
let plugin_project_path = {
|
||||||
|
let json5_path = root_dir.join("plugin.project.json5");
|
||||||
|
let json_path = root_dir.join("plugin.project.json");
|
||||||
|
if json5_path.exists() {
|
||||||
|
json5_path
|
||||||
|
} else {
|
||||||
|
json_path
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let plugin_snapshot = VfsSnapshot::dir(hashmap! {
|
let plugin_snapshot = VfsSnapshot::dir(hashmap! {
|
||||||
"default.project.json5" => snapshot_from_fs_path(&root_dir.join("plugin.project.json5"))?,
|
"default.project.json5" => snapshot_from_fs_path(&plugin_project_path)?,
|
||||||
"plugin" => VfsSnapshot::dir(hashmap! {
|
"plugin" => VfsSnapshot::dir(hashmap! {
|
||||||
"fmt" => snapshot_from_fs_path(&plugin_dir.join("fmt"))?,
|
"fmt" => snapshot_from_fs_path(&plugin_dir.join("fmt"))?,
|
||||||
"http" => snapshot_from_fs_path(&plugin_dir.join("http"))?,
|
"http" => snapshot_from_fs_path(&plugin_dir.join("http"))?,
|
||||||
|
|
|
||||||
|
|
@ -327,18 +327,18 @@ function ConfirmingPage:render()
|
||||||
self:setState({ showingAcceptConfirm = false })
|
self:setState({ showingAcceptConfirm = false })
|
||||||
end,
|
end,
|
||||||
}, {
|
}, {
|
||||||
Content = e("Frame", {
|
Content = e("Frame", {
|
||||||
Size = UDim2.fromScale(1, 1),
|
Size = UDim2.fromScale(1, 1),
|
||||||
BackgroundColor3 = theme.Background2,
|
BackgroundColor3 = theme.BackgroundColor,
|
||||||
BorderSizePixel = 0,
|
BorderSizePixel = 0,
|
||||||
}, {
|
}, {
|
||||||
Message = e("TextLabel", {
|
Message = e("TextLabel", {
|
||||||
Text = string.format(
|
Text = string.format(
|
||||||
"%d item%s not been reviewed.\n\nAccept selected changes and skip the rest?",
|
"%d item%s not been reviewed.\n\nAccept selected changes and skip the rest?",
|
||||||
self.state.unselectedCount,
|
self.state.unselectedCount,
|
||||||
self.state.unselectedCount == 1 and " has" or "s have"
|
self.state.unselectedCount == 1 and " has" or "s have"
|
||||||
),
|
),
|
||||||
FontFace = theme.Font.Regular,
|
FontFace = theme.Font.Main,
|
||||||
TextSize = theme.TextSize.Body,
|
TextSize = theme.TextSize.Body,
|
||||||
TextColor3 = theme.TextColor,
|
TextColor3 = theme.TextColor,
|
||||||
TextWrapped = true,
|
TextWrapped = true,
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ impl AdjacentMetadata {
|
||||||
.or_else(|| file_stem.strip_suffix(".local"))
|
.or_else(|| file_stem.strip_suffix(".local"))
|
||||||
.or_else(|| file_stem.strip_suffix(".legacy"))
|
.or_else(|| file_stem.strip_suffix(".legacy"))
|
||||||
.unwrap_or(file_stem);
|
.unwrap_or(file_stem);
|
||||||
|
|
||||||
// Try modern extension first, then fall back to legacy
|
// 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_json5 = path.with_file_name(format!("{base_name}.meta.json5"));
|
||||||
let meta_path_json = path.with_file_name(format!("{base_name}.meta.json"));
|
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)?;
|
let metadata = DirectoryMetadata::from_slice(&meta_contents, meta_path_json5)?;
|
||||||
return Ok(Some(metadata));
|
return Ok(Some(metadata));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy fallback: init.meta.json
|
// Legacy fallback: init.meta.json
|
||||||
let meta_path_json = path.join("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()? {
|
if let Some(meta_contents) = vfs.read(&meta_path_json).with_not_found()? {
|
||||||
let metadata = DirectoryMetadata::from_slice(&meta_contents, meta_path_json)?;
|
let metadata = DirectoryMetadata::from_slice(&meta_contents, meta_path_json)?;
|
||||||
return Ok(Some(metadata));
|
return Ok(Some(metadata));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(None)
|
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)?;
|
let metadata = AdjacentMetadata::from_slice(&meta_contents, meta_path_json5)?;
|
||||||
return Ok(Some(metadata));
|
return Ok(Some(metadata));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy fallback: .meta.json
|
// Legacy fallback: .meta.json
|
||||||
let mut meta_path_json = path.with_file_name(name);
|
let mut meta_path_json = path.with_file_name(name);
|
||||||
meta_path_json.set_extension("meta.json");
|
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)?;
|
let metadata = AdjacentMetadata::from_slice(&meta_contents, meta_path_json)?;
|
||||||
return Ok(Some(metadata));
|
return Ok(Some(metadata));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,9 +133,11 @@ fn get_dir_middleware<'path>(
|
||||||
(Middleware::LegacyScriptDir, "init.legacy.luau"),
|
(Middleware::LegacyScriptDir, "init.legacy.luau"),
|
||||||
(Middleware::CsvDir, "init.csv"),
|
(Middleware::CsvDir, "init.csv"),
|
||||||
// Legacy extensions (for backwards compatibility)
|
// 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::ModuleScriptDir, "init.lua"),
|
||||||
(Middleware::ServerScriptDir, "init.server.lua"),
|
(Middleware::LegacyScriptDir, "init.server.lua"),
|
||||||
(Middleware::ClientScriptDir, "init.client.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!("*.model.json5", JsonModel, ".model.json5"),
|
||||||
sync_rule!("*.json5", Json, ".json5", "*.meta.json5"),
|
sync_rule!("*.json5", Json, ".json5", "*.meta.json5"),
|
||||||
// Legacy Lua extensions (for backwards compatibility)
|
// Legacy Lua extensions (for backwards compatibility)
|
||||||
sync_rule!("*.server.lua", ServerScript, ".server.lua"),
|
// .server.lua → Script with RunContext.Legacy (old emitLegacyScripts behavior)
|
||||||
sync_rule!("*.client.lua", ClientScript, ".client.lua"),
|
// .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),
|
sync_rule!("*.lua", ModuleScript),
|
||||||
// Legacy JSON extensions (for backwards compatibility)
|
// Legacy JSON extensions (for backwards compatibility)
|
||||||
sync_rule!("*.project.json", Project, ".project.json"),
|
sync_rule!("*.project.json", Project, ".project.json"),
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,9 @@ pub fn name_for_inst<'old>(
|
||||||
| Middleware::CsvDir
|
| Middleware::CsvDir
|
||||||
| Middleware::ServerScriptDir
|
| Middleware::ServerScriptDir
|
||||||
| Middleware::ClientScriptDir
|
| Middleware::ClientScriptDir
|
||||||
| Middleware::ModuleScriptDir => {
|
| Middleware::ModuleScriptDir
|
||||||
|
| Middleware::LocalScriptDir
|
||||||
|
| Middleware::LegacyScriptDir => {
|
||||||
let name = if encode_invalid_chars {
|
let name = if encode_invalid_chars {
|
||||||
let encoded = encode_path_name(&new_inst.name);
|
let encoded = encode_path_name(&new_inst.name);
|
||||||
// Validate for issues not fixed by encoding (trailing space/dot, control chars, reserved names)
|
// 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 {
|
pub fn filter_out_property(inst: &Instance, prop_name: &str) -> bool {
|
||||||
match inst.class.as_str() {
|
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
|
// These properties shouldn't be set by scripts that are created via
|
||||||
// `$path` or via being on the file system.
|
// `$path` or via being on the file system.
|
||||||
prop_name == "Source" || prop_name == "ScriptGuid"
|
prop_name == "Source" || prop_name == "ScriptGuid"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue