mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 22:11:38 +00:00
RunContext refactor + sync updates
This commit is contained in:
parent
c7cddb72c2
commit
d3cc11659a
79 changed files with 1415 additions and 626 deletions
|
|
@ -8,11 +8,7 @@ use anyhow::Context;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
glob::Glob,
|
||||
path_serializer,
|
||||
project::ProjectNode,
|
||||
snapshot_middleware::{emit_legacy_scripts_default, Middleware},
|
||||
RojoRef,
|
||||
glob::Glob, path_serializer, project::ProjectNode, snapshot_middleware::Middleware, RojoRef,
|
||||
};
|
||||
|
||||
/// Rojo-specific metadata that can be associated with an instance or a snapshot
|
||||
|
|
@ -142,32 +138,26 @@ impl Default for InstanceMetadata {
|
|||
pub struct InstanceContext {
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
pub path_ignore_rules: Arc<Vec<PathIgnoreRule>>,
|
||||
pub emit_legacy_scripts: bool,
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
pub sync_rules: Vec<SyncRule>,
|
||||
/// Whether to decode Windows-invalid characters in file names.
|
||||
/// Characters like `%LT%`, `%GT%`, `%COLON%`, etc. will be decoded
|
||||
/// back to `<`, `>`, `:`, etc. in instance names sent to the plugin.
|
||||
#[serde(default)]
|
||||
/// Whether to decode special characters in file names.
|
||||
/// Characters like `%DOT%`, `%LT%`, `%GT%`, `%COLON%`, etc. will be decoded
|
||||
/// back to `.`, `<`, `>`, `:`, etc. in instance names sent to the plugin.
|
||||
/// Defaults to true.
|
||||
#[serde(default = "decode_windows_invalid_chars_default")]
|
||||
pub decode_windows_invalid_chars: bool,
|
||||
}
|
||||
|
||||
fn decode_windows_invalid_chars_default() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
impl InstanceContext {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
path_ignore_rules: Arc::new(Vec::new()),
|
||||
emit_legacy_scripts: emit_legacy_scripts_default().unwrap(),
|
||||
sync_rules: Vec::new(),
|
||||
decode_windows_invalid_chars: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_emit_legacy_scripts(emit_legacy_scripts: Option<bool>) -> Self {
|
||||
Self {
|
||||
emit_legacy_scripts: emit_legacy_scripts
|
||||
.or_else(emit_legacy_scripts_default)
|
||||
.unwrap(),
|
||||
..Self::new()
|
||||
decode_windows_invalid_chars: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -206,10 +196,6 @@ impl InstanceContext {
|
|||
self.sync_rules.clear();
|
||||
}
|
||||
|
||||
pub fn set_emit_legacy_scripts(&mut self, emit_legacy_scripts: bool) {
|
||||
self.emit_legacy_scripts = emit_legacy_scripts;
|
||||
}
|
||||
|
||||
/// Returns the middleware specified by the first sync rule that
|
||||
/// matches the provided path. This does not handle default syncing rules.
|
||||
pub fn get_user_sync_rule(&self, path: &Path) -> Option<&SyncRule> {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ metadata:
|
|||
ignore_unknown_instances: false
|
||||
relevant_paths: []
|
||||
context:
|
||||
emit_legacy_scripts: true
|
||||
decode_windows_invalid_chars: false
|
||||
decode_windows_invalid_chars: true
|
||||
specified_id: ~
|
||||
middleware: ~
|
||||
schema: ~
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ metadata:
|
|||
ignore_unknown_instances: false
|
||||
relevant_paths: []
|
||||
context:
|
||||
emit_legacy_scripts: true
|
||||
decode_windows_invalid_chars: false
|
||||
decode_windows_invalid_chars: true
|
||||
specified_id: ~
|
||||
middleware: ~
|
||||
schema: ~
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ metadata:
|
|||
ignore_unknown_instances: false
|
||||
relevant_paths: []
|
||||
context:
|
||||
emit_legacy_scripts: true
|
||||
decode_windows_invalid_chars: false
|
||||
decode_windows_invalid_chars: true
|
||||
specified_id: ~
|
||||
middleware: ~
|
||||
schema: ~
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ metadata:
|
|||
ignore_unknown_instances: false
|
||||
relevant_paths: []
|
||||
context:
|
||||
emit_legacy_scripts: true
|
||||
decode_windows_invalid_chars: false
|
||||
decode_windows_invalid_chars: true
|
||||
specified_id: ~
|
||||
middleware: ~
|
||||
schema: ~
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ added_instances:
|
|||
ignore_unknown_instances: false
|
||||
relevant_paths: []
|
||||
context:
|
||||
emit_legacy_scripts: true
|
||||
decode_windows_invalid_chars: false
|
||||
decode_windows_invalid_chars: true
|
||||
specified_id: ~
|
||||
middleware: ~
|
||||
schema: ~
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue