Skip to content

Commit 795332b

Browse files
authored
Merge pull request #132 from dev-five-git/rel-issue
Rel issue
2 parents 4484fd4 + a0a0eb9 commit 795332b

29 files changed

Lines changed: 1356 additions & 78 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"changes":{"crates/vespertide-macro/Cargo.toml":"Patch","crates/vespertide-exporter/Cargo.toml":"Patch","crates/vespertide-query/Cargo.toml":"Patch","crates/vespertide-core/Cargo.toml":"Patch","crates/vespertide-naming/Cargo.toml":"Patch","crates/vespertide/Cargo.toml":"Patch","crates/vespertide-cli/Cargo.toml":"Patch","crates/vespertide-planner/Cargo.toml":"Patch","crates/vespertide-loader/Cargo.toml":"Patch","crates/vespertide-config/Cargo.toml":"Patch"},"note":"Fix export issue","date":"2026-04-01T19:42:05.213092500Z"}

Cargo.lock

Lines changed: 31 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/vespertide-cli/src/commands/export.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub async fn cmd_export(orm: OrmArg, export_dir: Option<PathBuf>) -> Result<()>
125125

126126
// Ensure mod chain for SeaORM (must be done after all files are written)
127127
if matches!(orm_kind, Orm::SeaOrm) {
128-
for (_, rel_path) in &normalized_models {
128+
for (_table, rel_path) in &normalized_models {
129129
let out_path = build_output_path(&target_root, rel_path, orm_kind);
130130
ensure_mod_chain(&target_root, rel_path)
131131
.await
@@ -342,8 +342,7 @@ async fn load_models_recursive(base: &Path) -> Result<Vec<(TableDef, PathBuf)>>
342342
}
343343

344344
async fn ensure_mod_chain(root: &Path, rel_path: &Path) -> Result<()> {
345-
// Only needed for SeaORM (Rust) exports to wire modules.
346-
// Strip extension and ".vespertide" suffix from filename
345+
// SeaORM exports use a standard nested Rust module tree.
347346
let path_without_ext = rel_path.with_extension("");
348347
let path_stripped = if let Some(stem) = path_without_ext.file_stem().and_then(|s| s.to_str()) {
349348
let stripped_stem = stem.strip_suffix(".vespertide").unwrap_or(stem);
@@ -366,7 +365,7 @@ async fn ensure_mod_chain(root: &Path, rel_path: &Path) -> Result<()> {
366365
if comps.is_empty() {
367366
return Ok(());
368367
}
369-
// Build from deepest file up to root: dir/mod.rs should include child module.
368+
370369
while let Some(child) = comps.pop() {
371370
let dir = root.join(comps.join(std::path::MAIN_SEPARATOR_STR));
372371
let mod_path = dir.join("mod.rs");
@@ -375,13 +374,15 @@ async fn ensure_mod_chain(root: &Path, rel_path: &Path) -> Result<()> {
375374
{
376375
fs::create_dir_all(parent).await?;
377376
}
377+
378378
let mut content = if mod_path.exists() {
379379
fs::read_to_string(&mod_path).await?
380380
} else {
381381
String::new()
382382
};
383-
let decl = format!("pub mod {};", child);
384-
if !content.lines().any(|l| l.trim() == decl) {
383+
384+
let decl = format!("pub mod {child};");
385+
if !content.lines().any(|line| line.trim() == decl) {
385386
if !content.is_empty() && !content.ends_with('\n') {
386387
content.push('\n');
387388
}
@@ -390,6 +391,7 @@ async fn ensure_mod_chain(root: &Path, rel_path: &Path) -> Result<()> {
390391
fs::write(mod_path, content).await?;
391392
}
392393
}
394+
393395
Ok(())
394396
}
395397

@@ -535,7 +537,7 @@ mod tests {
535537
let content = std_fs::read_to_string(out).unwrap();
536538
assert!(content.contains("#[sea_orm(table_name = \"posts\")]"));
537539

538-
// mod.rs wiring
540+
// nested mod.rs wiring
539541
let root_mod = custom.join("mod.rs");
540542
let blog_mod = custom.join("blog/mod.rs");
541543
assert!(root_mod.exists());
@@ -779,6 +781,7 @@ mod tests {
779781
let blog_mod = std_fs::read_to_string(root.join("blog/mod.rs")).unwrap();
780782
assert!(root_mod.contains("pub mod blog;"));
781783
assert!(blog_mod.contains("pub mod post;"));
784+
assert!(!root_mod.contains("post_vespertide"));
782785
assert!(!blog_mod.contains("post_vespertide"));
783786
}
784787

crates/vespertide-exporter/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ thiserror = "2"
1616

1717
[dev-dependencies]
1818
rstest = "0.26"
19-
insta = { version = "1.46", features = ["yaml"] }
19+
insta = { version = "1.47", features = ["yaml"] }
2020

2121
[lints.rust]
2222
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }

0 commit comments

Comments
 (0)