mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-24 06:35:39 +00:00
Attach context to instances produced by middleware (#273)
This commit is contained in:
committed by
GitHub
parent
f0a602b48b
commit
4b89bb087a
@@ -64,7 +64,8 @@ impl SnapshotMiddleware for SnapshotDir {
|
|||||||
.metadata(
|
.metadata(
|
||||||
InstanceMetadata::new()
|
InstanceMetadata::new()
|
||||||
.instigating_source(entry.path())
|
.instigating_source(entry.path())
|
||||||
.relevant_paths(relevant_paths),
|
.relevant_paths(relevant_paths)
|
||||||
|
.context(context),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(meta_entry) = vfs.get(meta_path).with_not_found()? {
|
if let Some(meta_entry) = vfs.get(meta_path).with_not_found()? {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub struct SnapshotJsonModel;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotJsonModel {
|
impl SnapshotMiddleware for SnapshotJsonModel {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
_context: &InstanceContext,
|
context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -54,8 +54,11 @@ impl SnapshotMiddleware for SnapshotJsonModel {
|
|||||||
|
|
||||||
let mut snapshot = instance.core.into_snapshot(instance_name.to_owned());
|
let mut snapshot = instance.core.into_snapshot(instance_name.to_owned());
|
||||||
|
|
||||||
snapshot.metadata.instigating_source = Some(entry.path().to_path_buf().into());
|
snapshot.metadata = snapshot
|
||||||
snapshot.metadata.relevant_paths = vec![entry.path().to_path_buf()];
|
.metadata
|
||||||
|
.instigating_source(entry.path())
|
||||||
|
.relevant_paths(vec![entry.path().to_path_buf()])
|
||||||
|
.context(context);
|
||||||
|
|
||||||
Ok(Some(snapshot))
|
Ok(Some(snapshot))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ impl SnapshotMiddleware for SnapshotLua {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if entry.is_file() {
|
if entry.is_file() {
|
||||||
snapshot_lua_file(vfs, entry)
|
snapshot_lua_file(context, vfs, entry)
|
||||||
} else {
|
} else {
|
||||||
// At this point, our entry is definitely a directory!
|
// At this point, our entry is definitely a directory!
|
||||||
|
|
||||||
@@ -54,7 +54,11 @@ impl SnapshotMiddleware for SnapshotLua {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Core routine for turning Lua files into snapshots.
|
/// Core routine for turning Lua files into snapshots.
|
||||||
fn snapshot_lua_file<F: VfsFetcher>(vfs: &Vfs<F>, entry: &VfsEntry) -> SnapshotInstanceResult {
|
fn snapshot_lua_file<F: VfsFetcher>(
|
||||||
|
context: &InstanceContext,
|
||||||
|
vfs: &Vfs<F>,
|
||||||
|
entry: &VfsEntry,
|
||||||
|
) -> SnapshotInstanceResult {
|
||||||
let file_name = entry.path().file_name().unwrap().to_string_lossy();
|
let file_name = entry.path().file_name().unwrap().to_string_lossy();
|
||||||
|
|
||||||
let (class_name, instance_name) = if let Some(name) = match_trailing(&file_name, ".server.lua")
|
let (class_name, instance_name) = if let Some(name) = match_trailing(&file_name, ".server.lua")
|
||||||
@@ -89,7 +93,8 @@ fn snapshot_lua_file<F: VfsFetcher>(vfs: &Vfs<F>, entry: &VfsEntry) -> SnapshotI
|
|||||||
.metadata(
|
.metadata(
|
||||||
InstanceMetadata::new()
|
InstanceMetadata::new()
|
||||||
.instigating_source(entry.path())
|
.instigating_source(entry.path())
|
||||||
.relevant_paths(vec![entry.path().to_path_buf(), meta_path.clone()]),
|
.relevant_paths(vec![entry.path().to_path_buf(), meta_path.clone()])
|
||||||
|
.context(context),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(meta_entry) = vfs.get(meta_path).with_not_found()? {
|
if let Some(meta_entry) = vfs.get(meta_path).with_not_found()? {
|
||||||
@@ -116,7 +121,7 @@ fn snapshot_init<F: VfsFetcher>(
|
|||||||
|
|
||||||
if let Some(init_entry) = vfs.get(init_path).with_not_found()? {
|
if let Some(init_entry) = vfs.get(init_path).with_not_found()? {
|
||||||
if let Some(dir_snapshot) = SnapshotDir::from_vfs(context, vfs, folder_entry)? {
|
if let Some(dir_snapshot) = SnapshotDir::from_vfs(context, vfs, folder_entry)? {
|
||||||
if let Some(mut init_snapshot) = snapshot_lua_file(vfs, &init_entry)? {
|
if let Some(mut init_snapshot) = snapshot_lua_file(context, vfs, &init_entry)? {
|
||||||
if dir_snapshot.class_name != "Folder" {
|
if dir_snapshot.class_name != "Folder" {
|
||||||
panic!(
|
panic!(
|
||||||
"init.lua, init.server.lua, and init.client.lua can \
|
"init.lua, init.server.lua, and init.client.lua can \
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ pub struct SnapshotRbxlx;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotRbxlx {
|
impl SnapshotMiddleware for SnapshotRbxlx {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
_context: &InstanceContext,
|
context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -38,7 +38,8 @@ impl SnapshotMiddleware for SnapshotRbxlx {
|
|||||||
.metadata(
|
.metadata(
|
||||||
InstanceMetadata::new()
|
InstanceMetadata::new()
|
||||||
.instigating_source(entry.path())
|
.instigating_source(entry.path())
|
||||||
.relevant_paths(vec![entry.path().to_path_buf()]),
|
.relevant_paths(vec![entry.path().to_path_buf()])
|
||||||
|
.context(context),
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(Some(snapshot))
|
Ok(Some(snapshot))
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub struct SnapshotRbxm;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotRbxm {
|
impl SnapshotMiddleware for SnapshotRbxm {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
_context: &InstanceContext,
|
context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -48,7 +48,8 @@ impl SnapshotMiddleware for SnapshotRbxm {
|
|||||||
.metadata(
|
.metadata(
|
||||||
InstanceMetadata::new()
|
InstanceMetadata::new()
|
||||||
.instigating_source(entry.path())
|
.instigating_source(entry.path())
|
||||||
.relevant_paths(vec![entry.path().to_path_buf()]),
|
.relevant_paths(vec![entry.path().to_path_buf()])
|
||||||
|
.context(context),
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(Some(snapshot))
|
Ok(Some(snapshot))
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ pub struct SnapshotRbxmx;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotRbxmx {
|
impl SnapshotMiddleware for SnapshotRbxmx {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
_context: &InstanceContext,
|
context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -40,7 +40,8 @@ impl SnapshotMiddleware for SnapshotRbxmx {
|
|||||||
.metadata(
|
.metadata(
|
||||||
InstanceMetadata::new()
|
InstanceMetadata::new()
|
||||||
.instigating_source(entry.path())
|
.instigating_source(entry.path())
|
||||||
.relevant_paths(vec![entry.path().to_path_buf()]),
|
.relevant_paths(vec![entry.path().to_path_buf()])
|
||||||
|
.context(context),
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(Some(snapshot))
|
Ok(Some(snapshot))
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub struct SnapshotTxt;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotTxt {
|
impl SnapshotMiddleware for SnapshotTxt {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
_context: &InstanceContext,
|
context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -54,7 +54,8 @@ impl SnapshotMiddleware for SnapshotTxt {
|
|||||||
.metadata(
|
.metadata(
|
||||||
InstanceMetadata::new()
|
InstanceMetadata::new()
|
||||||
.instigating_source(entry.path())
|
.instigating_source(entry.path())
|
||||||
.relevant_paths(vec![entry.path().to_path_buf(), meta_path.clone()]),
|
.relevant_paths(vec![entry.path().to_path_buf(), meta_path.clone()])
|
||||||
|
.context(context),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(meta_entry) = vfs.get(meta_path).with_not_found()? {
|
if let Some(meta_entry) = vfs.get(meta_path).with_not_found()? {
|
||||||
|
|||||||
Reference in New Issue
Block a user