Skip to content

Switching from glob to wax to fix symlink follow issue #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ dirs = "6.0.0"
fs_extra = "1.3.0"
futures = "0.3.31"
futures-util = "0.3.31"
glob = "0.3.2"
heck = "0.5.0"
http = "1.2.0"
http-body-util = "0.1.2"
Expand Down Expand Up @@ -107,6 +106,7 @@ uuid = "1.13.2"
version-compare = "0.2.0"
wac-graph = "=0.6.1"
walkdir = "2.5.0"
wax = "0.6.0"
wit-bindgen-rust = "=0.26.0"
wit-encoder = "=0.221.2"
wit-parser = "=0.221.3"
Expand Down
2 changes: 1 addition & 1 deletion wasm-rpc-stubgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ clap = { workspace = true }
colored = { workspace = true }
dir-diff = { workspace = true }
fs_extra = { workspace = true }
glob = { workspace = true }
heck = { workspace = true }
id-arena = { workspace = true }
indexmap = { workspace = true }
Expand All @@ -61,6 +60,7 @@ tokio = { workspace = true }
toml = { workspace = true }
wac-graph = { workspace = true }
walkdir = { workspace = true }
wax = { workspace = true }
wit-bindgen-rust = { workspace = true }
wit-encoder = { workspace = true }
wit-parser = { workspace = true }
Expand Down
34 changes: 19 additions & 15 deletions wasm-rpc-stubgen/src/commands/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use crate::{commands, naming, WasmRpcOverride};
use anyhow::{anyhow, bail, Context, Error};
use colored::control::SHOULD_COLORIZE;
use colored::Colorize;
use glob::{glob_with, MatchOptions};
use golem_wasm_rpc::WASM_RPC_VERSION;
use itertools::Itertools;
use serde::Serialize;
Expand All @@ -35,6 +34,7 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use std::time::SystemTime;
use walkdir::WalkDir;
use wax::{Glob, LinkBehavior, WalkBehavior};

pub struct Config<CPE: ComponentPropertiesExtensions> {
pub app_source_mode: ApplicationSourceMode,
Expand Down Expand Up @@ -1289,25 +1289,29 @@ fn compile_and_collect_globs(root_dir: &Path, globs: &[String]) -> Result<Vec<Pa
globs
.iter()
.map(|pattern| {
glob_with(
&format!("{}/{}", root_dir.to_string_lossy(), pattern),
MatchOptions {
case_sensitive: true,
require_literal_separator: false,
require_literal_leading_dot: true,
Glob::new(pattern)
.with_context(|| format!("Failed to compile glob expression: {}", pattern))
})
.collect::<Result<Vec<_>, _>>()
.map_err(|err| anyhow!(err))?
.iter()
.flat_map(|glob| {
glob.walk_with_behavior(
root_dir,
WalkBehavior {
link: LinkBehavior::ReadFile,
..WalkBehavior::default()
},
)
.with_context(|| format!("Failed to compile glob expression: {}", pattern))
.collect::<Vec<_>>()
})
.map(|walk_item| {
walk_item
.map(|entry| entry.path().to_path_buf())
.with_context(|| "Failed to get path from item when evaluating glob expressions")
})
.collect::<Result<Vec<_>, _>>()
.map_err(|err| anyhow!(err))
.and_then(|paths| {
paths
.into_iter()
.flatten()
.collect::<Result<Vec<_>, _>>()
.map_err(|err| anyhow!(err))
})
}

fn create_generated_base_wit<CPE: ComponentPropertiesExtensions>(
Expand Down