feat: add init command to initialize new projects and update README#28
feat: add init command to initialize new projects and update README#28Bechma merged 2 commits intocyberfabric:mainfrom
Conversation
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR moves server config-path handling from compile-time template substitution to runtime via the CF_CLI_CONFIG environment variable, removes liquid templating, and promotes the CLI Changes
Sequence DiagramsequenceDiagram
participant User as User/CLI
participant CLI as CLI Handler
participant Common as common.rs
participant Cargo as Cargo Process
participant GenServer as Generated Server
participant Env as Environment
rect rgba(100, 150, 200, 0.5)
note over User,Env: Runtime configuration via CF_CLI_CONFIG
User->>CLI: Run `build` / `run` with config_path
CLI->>Common: generate_server_structure(project, deps)
Common->>Common: Write main.rs reading CF_CLI_CONFIG (no config_path substitution)
CLI->>Common: cargo_command(subcommand, path, config_path, ...)
Common->>Cargo: Spawn cargo with CF_CLI_CONFIG env set
Cargo->>GenServer: Build/Run generated server
GenServer->>Env: Read CF_CLI_CONFIG at runtime
Env-->>GenServer: Provide config path
GenServer->>GenServer: Load config and start
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/cli/src/common.rs (1)
389-402: Test should verify hyphen-to-underscore conversion.If the hyphen fix is applied, update the test to verify that dependency names with hyphens are correctly converted to valid Rust identifiers:
🧪 Proposed test enhancement
#[test] fn generated_server_main_reads_config_from_env_and_includes_dependencies() { let dependencies = CargoTomlDependencies::from([ ("module_a".to_owned(), Default::default()), ("module_b".to_owned(), Default::default()), + ("api-db-handler".to_owned(), Default::default()), ]); let main_rs = prepare_cargo_server_main(&dependencies); assert!(main_rs.contains("std::env::var_os(\"CF_CLI_CONFIG\")")); assert!(main_rs.contains("use module_a as _;")); assert!(main_rs.contains("use module_b as _;")); + assert!(main_rs.contains("use api_db_handler as _;")); + assert!(!main_rs.contains("use api-db-handler as _;")); assert!(!main_rs.contains("{{dependencies}}")); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/cli/src/common.rs` around lines 389 - 402, The test generated_server_main_reads_config_from_env_and_includes_dependencies needs to also assert that dependency names containing hyphens are converted to valid Rust identifiers (hyphen -> underscore) when generating the main.rs; update the test's CargoTomlDependencies input to include entries with hyphens (e.g., "module-a" and "module-b") and change the assertions to expect "use module_a as _;" and "use module_b as _;" (still ensure "{{dependencies}}" is not present), so prepare_cargo_server_main and the generation logic are validated for hyphen-to-underscore conversion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/cli/src/common.rs`:
- Around line 389-402: The test
generated_server_main_reads_config_from_env_and_includes_dependencies needs to
also assert that dependency names containing hyphens are converted to valid Rust
identifiers (hyphen -> underscore) when generating the main.rs; update the
test's CargoTomlDependencies input to include entries with hyphens (e.g.,
"module-a" and "module-b") and change the assertions to expect "use module_a as
_;" and "use module_b as _;" (still ensure "{{dependencies}}" is not present),
so prepare_cargo_server_main and the generation logic are validated for
hyphen-to-underscore conversion.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: beaec668-f1d3-4aef-9639-f7b6b7c888d2
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (10)
Cargo.tomlREADME.mdSKILLS.mdcrates/cli/Cargo.tomlcrates/cli/src/build/mod.rscrates/cli/src/common.rscrates/cli/src/init/mod.rscrates/cli/src/lib.rscrates/cli/src/mod/mod.rscrates/cli/src/run/run_loop.rs
💤 Files with no reviewable changes (3)
- Cargo.toml
- crates/cli/Cargo.toml
- crates/cli/src/mod/mod.rs
Signed-off-by: Bechma <19294519+Bechma@users.noreply.github.com>
Summary by CodeRabbit
New Features
initsubcommand at the top-level CLI.Documentation
mod init→init.Chores
liquiddependency from workspace and CLI crate.