fix: lack of .model.json support

This commit is contained in:
2025-12-15 20:26:25 +01:00
parent 5c396322d9
commit 790312a5b0
11 changed files with 80 additions and 13 deletions

View File

@@ -35,19 +35,12 @@ pub fn snapshot_json_model(
format!("File is not a valid JSON model: {}", path.display())
})?;
if let Some(top_level_name) = &instance.name {
let new_name = format!("{}.model.json", top_level_name);
// If the JSON has a name property, preserve it in metadata for syncback
let specified_name = instance.name.clone();
log::warn!(
"Model at path {} had a top-level Name field. \
This field has been ignored since Rojo 6.0.\n\
Consider removing this field and renaming the file to {}.",
new_name,
path.display()
);
}
instance.name = Some(name.to_owned());
// Use the name from JSON if present, otherwise fall back to filename-derived name
let instance_name = specified_name.clone().unwrap_or_else(|| name.to_owned());
instance.name = Some(instance_name);
let id = instance.id.take().map(RojoRef::new);
let schema = instance.schema.take();
@@ -62,7 +55,8 @@ pub fn snapshot_json_model(
.relevant_paths(vec![path.to_path_buf()])
.context(context)
.specified_id(id)
.schema(schema);
.schema(schema)
.specified_name(specified_name);
Ok(Some(snapshot))
}