fix relevant extensions (#2241)
* updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
		
							
								
								
									
										23
									
								
								src-tauri/Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										23
									
								
								src-tauri/Cargo.lock
									
									
									
										generated
									
									
									
								
							@ -751,6 +751,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "clap_builder",
 | 
			
		||||
 "clap_derive",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
@ -763,6 +764,20 @@ dependencies = [
 | 
			
		||||
 "anstyle",
 | 
			
		||||
 "clap_lex",
 | 
			
		||||
 "strsim 0.11.1",
 | 
			
		||||
 "unicase",
 | 
			
		||||
 "unicode-width",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "clap_derive"
 | 
			
		||||
version = "4.5.4"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "heck 0.5.0",
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
 "quote",
 | 
			
		||||
 "syn 2.0.60",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
@ -2412,6 +2427,7 @@ dependencies = [
 | 
			
		||||
 "base64 0.22.0",
 | 
			
		||||
 "bson",
 | 
			
		||||
 "chrono",
 | 
			
		||||
 "clap",
 | 
			
		||||
 "dashmap",
 | 
			
		||||
 "databake",
 | 
			
		||||
 "derive-docs",
 | 
			
		||||
@ -2471,6 +2487,7 @@ dependencies = [
 | 
			
		||||
 "bigdecimal",
 | 
			
		||||
 "bytes",
 | 
			
		||||
 "chrono",
 | 
			
		||||
 "clap",
 | 
			
		||||
 "data-encoding",
 | 
			
		||||
 "format_serde_error",
 | 
			
		||||
 "futures",
 | 
			
		||||
@ -5886,6 +5903,12 @@ version = "1.11.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "unicode-width"
 | 
			
		||||
version = "0.1.11"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "untrusted"
 | 
			
		||||
version = "0.9.0"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								src/wasm-lib/Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								src/wasm-lib/Cargo.lock
									
									
									
										generated
									
									
									
								
							@ -1974,6 +1974,7 @@ dependencies = [
 | 
			
		||||
 "bigdecimal",
 | 
			
		||||
 "bytes",
 | 
			
		||||
 "chrono",
 | 
			
		||||
 "clap",
 | 
			
		||||
 "data-encoding",
 | 
			
		||||
 "format_serde_error",
 | 
			
		||||
 "futures",
 | 
			
		||||
@ -4726,6 +4727,7 @@ version = "0.1.0"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "anyhow",
 | 
			
		||||
 "bson",
 | 
			
		||||
 "clap",
 | 
			
		||||
 "console_error_panic_hook",
 | 
			
		||||
 "futures",
 | 
			
		||||
 "gloo-utils",
 | 
			
		||||
 | 
			
		||||
@ -11,6 +11,7 @@ crate-type = ["cdylib"]
 | 
			
		||||
 | 
			
		||||
[dependencies]
 | 
			
		||||
bson = { version = "2.10.0", features = ["uuid-1", "chrono"] }
 | 
			
		||||
clap = "4.5.4"
 | 
			
		||||
gloo-utils = "0.2.0"
 | 
			
		||||
kcl-lib = { path = "kcl" }
 | 
			
		||||
kittycad = { workspace = true }
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,7 @@ async-recursion = "1.1.0"
 | 
			
		||||
async-trait = "0.1.80"
 | 
			
		||||
base64 = "0.22.0"
 | 
			
		||||
chrono = "0.4.38"
 | 
			
		||||
clap = { version = "4.5.4", features = ["cargo", "derive", "env", "unicode"], optional = true }
 | 
			
		||||
clap = { version = "4.5.4", default-features = false, optional = true }
 | 
			
		||||
dashmap = "5.5.3"
 | 
			
		||||
databake = { version = "0.1.7", features = ["derive"] }
 | 
			
		||||
derive-docs = { version = "0.1.17",  path = "../derive-docs" }
 | 
			
		||||
@ -24,7 +24,7 @@ form_urlencoded = "1.2.1"
 | 
			
		||||
futures = { version = "0.3.30" }
 | 
			
		||||
git_rev = "0.1.0"
 | 
			
		||||
gltf-json = "1.4.0"
 | 
			
		||||
kittycad = { workspace = true }
 | 
			
		||||
kittycad = { workspace = true, features = ["clap"] }
 | 
			
		||||
kittycad-execution-plan-macros = { workspace = true }
 | 
			
		||||
kittycad-execution-plan-traits = { workspace = true }
 | 
			
		||||
lazy_static = "1.4.0"
 | 
			
		||||
@ -61,7 +61,7 @@ tokio-tungstenite = { version = "0.21.0", features = ["rustls-tls-native-roots"]
 | 
			
		||||
tower-lsp = { version = "0.20.0", features = ["proposed"] }
 | 
			
		||||
 | 
			
		||||
[features]
 | 
			
		||||
default = ["engine"]
 | 
			
		||||
default = ["cli", "engine"]
 | 
			
		||||
cli = ["dep:clap"]
 | 
			
		||||
engine = []
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -3,9 +3,23 @@
 | 
			
		||||
use std::path::Path;
 | 
			
		||||
 | 
			
		||||
use anyhow::Result;
 | 
			
		||||
use clap::ValueEnum;
 | 
			
		||||
 | 
			
		||||
use crate::settings::types::file::FileEntry;
 | 
			
		||||
 | 
			
		||||
lazy_static::lazy_static! {
 | 
			
		||||
    static ref RELEVANT_EXTENSIONS: Vec<String> = {
 | 
			
		||||
        let mut relevant_extensions = vec!["kcl".to_string(), "stp".to_string(), "glb".to_string()];
 | 
			
		||||
        let named_extensions = kittycad::types::FileImportFormat::value_variants()
 | 
			
		||||
            .iter()
 | 
			
		||||
            .map(|x| format!("{}", x))
 | 
			
		||||
            .collect::<Vec<String>>();
 | 
			
		||||
        // Add all the default import formats.
 | 
			
		||||
        relevant_extensions.extend_from_slice(&named_extensions);
 | 
			
		||||
        relevant_extensions
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Walk a directory recursively and return a list of all files.
 | 
			
		||||
#[async_recursion::async_recursion]
 | 
			
		||||
pub async fn walk_dir<P: AsRef<Path> + Send>(dir: P) -> Result<FileEntry> {
 | 
			
		||||
@ -27,6 +41,9 @@ pub async fn walk_dir<P: AsRef<Path> + Send>(dir: P) -> Result<FileEntry> {
 | 
			
		||||
        if e.file_type().await?.is_dir() {
 | 
			
		||||
            children.push(walk_dir(&e.path()).await?);
 | 
			
		||||
        } else {
 | 
			
		||||
            if !is_relevant_file(&e.path())? {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            children.push(FileEntry {
 | 
			
		||||
                name: e.file_name().to_string_lossy().to_string(),
 | 
			
		||||
                path: e.path().display().to_string(),
 | 
			
		||||
@ -40,3 +57,12 @@ pub async fn walk_dir<P: AsRef<Path> + Send>(dir: P) -> Result<FileEntry> {
 | 
			
		||||
 | 
			
		||||
    Ok(entry)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Check if a file is relevant for the application.
 | 
			
		||||
fn is_relevant_file<P: AsRef<Path>>(path: P) -> Result<bool> {
 | 
			
		||||
    if let Some(ext) = path.as_ref().extension() {
 | 
			
		||||
        Ok(RELEVANT_EXTENSIONS.contains(&ext.to_string_lossy().to_string()))
 | 
			
		||||
    } else {
 | 
			
		||||
        Ok(false)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user