fix(scaffold): treat --path as project root, not parent directory #95

Merged
mahmoud merged 1 commit from development_fix_hero_docs_new_path_nesting into development 2026-04-21 05:49:20 +00:00
Owner

Summary

hero_docs new --name N --path P now scaffolds directly into P; previously it would create a redundant P/N/ nesting. When --path is omitted, files are written into the current directory (same no-nesting rule). The RPC method docs.new picks up the fix automatically.

Closes #91

Changes

  • crates/hero_books_docusaurus/src/scaffold.rs — parameter renamed base_pathproject_root; path used as root directly; non-empty-target check with --force to overwrite guard; 5 tests updated, 1 new regression test (test_scaffold_uses_path_as_root).
  • src/bin/hero_docs.rs--path help text changed to "Project directory to create (defaults to current directory)"; the "Project created at" log line now prints project_root.display() instead of base_path.join(&args.name).display().
  • crates/hero_books_server/src/web/rpc.rshandle_docs_new defaults path to <docusaurus_cache>/<input_hash>/ when the caller omits it, preventing concurrent anonymous jobs from colliding at the shared cache root. handle_docs_generate and handle_docs_job_status untouched.
  • crates/hero_books_docusaurus/README.md — added ### Subcommand: new and ### Subcommand: generate sections; updated Usage and Examples to show the subcommand structure; added a "Behavior change" note for --path.

Test Results

  • Build: cargo build -p hero_books_docusaurus -p hero_books_server — ok.
  • hero_books_docusaurus scaffold tests: 6/6 passed (including the new regression test).
  • hero_books_server library tests: 16/16 passed.
  • cargo fmt --check — clean after fmt was applied to the two modified crates.

Notes

  • No backwards-compatibility shim. The old behavior (path as parent directory) is removed outright.
  • The deterministic output_path returned by docs.jobStatus is still <cache>/<hash>/build and is unaffected by this change.
  • scaffold() keeps the same arity and types; only the semantics of the path argument changed, and the argument was renamed to project_root for clarity.
## Summary `hero_docs new --name N --path P` now scaffolds directly into `P`; previously it would create a redundant `P/N/` nesting. When `--path` is omitted, files are written into the current directory (same no-nesting rule). The RPC method `docs.new` picks up the fix automatically. ## Related Issue Closes https://forge.ourworld.tf/lhumina_code/hero_books/issues/91 ## Changes - **`crates/hero_books_docusaurus/src/scaffold.rs`** — parameter renamed `base_path` → `project_root`; path used as root directly; non-empty-target check with `--force to overwrite` guard; 5 tests updated, 1 new regression test (`test_scaffold_uses_path_as_root`). - **`src/bin/hero_docs.rs`** — `--path` help text changed to "Project directory to create (defaults to current directory)"; the "Project created at" log line now prints `project_root.display()` instead of `base_path.join(&args.name).display()`. - **`crates/hero_books_server/src/web/rpc.rs`** — `handle_docs_new` defaults `path` to `<docusaurus_cache>/<input_hash>/` when the caller omits it, preventing concurrent anonymous jobs from colliding at the shared cache root. `handle_docs_generate` and `handle_docs_job_status` untouched. - **`crates/hero_books_docusaurus/README.md`** — added `### Subcommand: new` and `### Subcommand: generate` sections; updated Usage and Examples to show the subcommand structure; added a "Behavior change" note for `--path`. ## Test Results - Build: `cargo build -p hero_books_docusaurus -p hero_books_server` — ok. - `hero_books_docusaurus` scaffold tests: 6/6 passed (including the new regression test). - `hero_books_server` library tests: 16/16 passed. - `cargo fmt --check` — clean after fmt was applied to the two modified crates. ## Notes - No backwards-compatibility shim. The old behavior (path as parent directory) is removed outright. - The deterministic `output_path` returned by `docs.jobStatus` is still `<cache>/<hash>/build` and is unaffected by this change. - `scaffold()` keeps the same arity and types; only the semantics of the path argument changed, and the argument was renamed to `project_root` for clarity.
fix(scaffold): treat --path as project root, not parent directory
All checks were successful
Test / test (pull_request) Successful in 6m43s
Test / integration (pull_request) Successful in 4m11s
fa3c7c6210
hero_docs new --name N --path P now scaffolds directly into P — previously
it would create a redundant P/N/ nesting. When --path is omitted, files
are written into the current directory (same no-nesting rule). The RPC
method docs.new (which shells out to the CLI) picks up the fix automatically;
when it is called without an explicit path, it now defaults to a unique
<docusaurus_cache>/<input_hash>/ subdirectory so concurrent anonymous jobs
do not collide at the shared cache root.

- scaffold.rs: parameter renamed base_path → project_root; path used as
  root directly; non-empty-target check with "--force to overwrite" guard;
  tests updated; added regression test test_scaffold_uses_path_as_root.
- hero_docs.rs: --path help text and log line updated.
- rpc.rs: handle_docs_new defaults path to <cache>/<input_hash>/ when
  caller omits it. docs.generate and docs.jobStatus untouched.
- README: documents the new and generate subcommands explicitly; includes
  a behavior-change note for --path.

#91
mahmoud merged commit db0abb59e5 into development 2026-04-21 05:49:20 +00:00
mahmoud deleted branch development_fix_hero_docs_new_path_nesting 2026-04-21 05:49:31 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_books!95
No description provided.