mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 14:15:24 +00:00
Add support for .meta.json files associated with .txt files
This commit is contained in:
@@ -9,6 +9,7 @@ metadata:
|
|||||||
Path: /foo.txt
|
Path: /foo.txt
|
||||||
relevant_paths:
|
relevant_paths:
|
||||||
- /foo.txt
|
- /foo.txt
|
||||||
|
- /foo.meta.json
|
||||||
name: foo
|
name: foo
|
||||||
class_name: StringValue
|
class_name: StringValue
|
||||||
properties:
|
properties:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ metadata:
|
|||||||
Path: /foo/default.project.json
|
Path: /foo/default.project.json
|
||||||
relevant_paths:
|
relevant_paths:
|
||||||
- /foo/other.txt
|
- /foo/other.txt
|
||||||
|
- /foo/other.meta.json
|
||||||
- /foo/default.project.json
|
- /foo/default.project.json
|
||||||
name: path-project
|
name: path-project
|
||||||
class_name: StringValue
|
class_name: StringValue
|
||||||
|
|||||||
@@ -4,11 +4,14 @@ use maplit::hashmap;
|
|||||||
use rbx_dom_weak::{RbxId, RbxTree, RbxValue};
|
use rbx_dom_weak::{RbxId, RbxTree, RbxValue};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
imfs::{FileSnapshot, Imfs, ImfsEntry, ImfsFetcher, ImfsSnapshot},
|
imfs::{FileSnapshot, FsResultExt, Imfs, ImfsEntry, ImfsFetcher, ImfsSnapshot},
|
||||||
snapshot::{InstanceMetadata, InstanceSnapshot},
|
snapshot::{InstanceMetadata, InstanceSnapshot},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware};
|
use super::{
|
||||||
|
meta_file::AdjacentMetadata,
|
||||||
|
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
|
};
|
||||||
|
|
||||||
pub struct SnapshotTxt;
|
pub struct SnapshotTxt;
|
||||||
|
|
||||||
@@ -49,18 +52,30 @@ impl SnapshotMiddleware for SnapshotTxt {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Some(InstanceSnapshot {
|
let meta_path = entry
|
||||||
|
.path()
|
||||||
|
.with_file_name(format!("{}.meta.json", instance_name));
|
||||||
|
|
||||||
|
let mut snapshot = InstanceSnapshot {
|
||||||
snapshot_id: None,
|
snapshot_id: None,
|
||||||
metadata: InstanceMetadata {
|
metadata: InstanceMetadata {
|
||||||
instigating_source: Some(entry.path().to_path_buf().into()),
|
instigating_source: Some(entry.path().to_path_buf().into()),
|
||||||
relevant_paths: vec![entry.path().to_path_buf()],
|
relevant_paths: vec![entry.path().to_path_buf(), meta_path.clone()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
name: Cow::Owned(instance_name),
|
name: Cow::Owned(instance_name),
|
||||||
class_name: Cow::Borrowed("StringValue"),
|
class_name: Cow::Borrowed("StringValue"),
|
||||||
properties,
|
properties,
|
||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
}))
|
};
|
||||||
|
|
||||||
|
if let Some(meta_entry) = imfs.get(meta_path).with_not_found()? {
|
||||||
|
let meta_contents = meta_entry.contents(imfs)?;
|
||||||
|
let mut metadata = AdjacentMetadata::from_slice(meta_contents);
|
||||||
|
metadata.apply_all(&mut snapshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Some(snapshot))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_instance(tree: &RbxTree, id: RbxId) -> SnapshotFileResult {
|
fn from_instance(tree: &RbxTree, id: RbxId) -> SnapshotFileResult {
|
||||||
|
|||||||
@@ -15,4 +15,5 @@ metadata:
|
|||||||
Path: /foo.txt
|
Path: /foo.txt
|
||||||
relevant_paths:
|
relevant_paths:
|
||||||
- /foo.txt
|
- /foo.txt
|
||||||
|
- /foo.meta.json
|
||||||
children: []
|
children: []
|
||||||
|
|||||||
@@ -27,4 +27,5 @@ children:
|
|||||||
Path: /foo/src/hello.txt
|
Path: /foo/src/hello.txt
|
||||||
relevant_paths:
|
relevant_paths:
|
||||||
- /foo/src/hello.txt
|
- /foo/src/hello.txt
|
||||||
|
- /foo/src/hello.meta.json
|
||||||
children: []
|
children: []
|
||||||
|
|||||||
Reference in New Issue
Block a user