-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/local memory provider #42
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Changelog | ||
|
|
||
| ## 0.1.4 | ||
|
|
||
| ### Fixed | ||
|
|
||
| - Fixed npm executable metadata so npm preserves the `codra` binary mapping during publish. | ||
| - Removed reliance on stale globally installed binaries during validation. | ||
|
|
||
| ## 0.1.3 | ||
|
|
||
| ### Fixed | ||
|
|
||
| - Fixed npm `bin` metadata so `npx @talocode/codra` executes the packaged Codra binary. | ||
| - Prevented npx from falling back to stale globally installed binaries. | ||
|
|
||
| ## 0.1.2 | ||
|
|
||
| ### Fixed | ||
|
|
||
| - Fixed the npm package runtime version mismatch so `codra --version` matches the published package version. | ||
| - Added validation to prevent stale bundled native binaries from being published. | ||
|
|
||
| ## 0.1.1 | ||
|
|
||
| - Added `codra understand` repo scanning and local knowledge-graph output. | ||
| - Wrote `.codra/graph/knowledge-graph.json` and `.codra/graph/summary.md`. | ||
| - Added repository signal detection for package manager, languages, frameworks, scripts, docs, tests, and routes. | ||
| - Documented the canonical npm package path as `packages/codra-npm-cli`. | ||
| - Moved the stale duplicate `packages/codra-cli` out of the workspace before the release work. | ||
|
|
||
| ## 0.1.0 | ||
|
|
||
| - First terminal release of Codra as `@talocode/codra`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| use crate::registry::{list_services, ServiceRecord}; | ||
| use crate::cli::DeployOutputFormat; | ||
| use serde::Serialize; | ||
| use std::env; | ||
| use std::path::PathBuf; | ||
|
|
||
| #[derive(Debug, Serialize)] | ||
| #[serde(rename_all = "camelCase")] | ||
| struct DeployStatusOutput { | ||
| workspace: String, | ||
| registry_exists: bool, | ||
| services: Vec<ServiceRecord>, | ||
| } | ||
|
|
||
| pub fn execute_status(args: &[String]) -> Result<(), String> { | ||
| if args.iter().any(|arg| arg == "--help" || arg == "-h") { | ||
| print_status_help(); | ||
| return Ok(()); | ||
| } | ||
|
|
||
| let (format, workspace, service_filter) = parse_args(args)?; | ||
| let registry_path = crate::registry::services_registry_path(&workspace); | ||
| let registry_exists = registry_path.exists(); | ||
| let mut services = list_services(&workspace).map_err(|err| err.to_string())?; | ||
|
|
||
| if let Some(service_name) = service_filter { | ||
| services.retain(|service| service.service_name == service_name); | ||
| } | ||
|
|
||
| services.sort_by(|left, right| { | ||
| left.project | ||
| .cmp(&right.project) | ||
| .then_with(|| left.service_name.cmp(&right.service_name)) | ||
| }); | ||
|
|
||
| match format { | ||
| DeployOutputFormat::Human => print_human(&workspace, registry_exists, &services), | ||
| DeployOutputFormat::Json => { | ||
| let body = serde_json::to_string_pretty(&DeployStatusOutput { | ||
| workspace: workspace.display().to_string(), | ||
| registry_exists, | ||
| services, | ||
| }) | ||
| .map_err(|err| err.to_string())?; | ||
| println!("{body}"); | ||
| } | ||
| } | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| fn parse_args(args: &[String]) -> Result<(DeployOutputFormat, PathBuf, Option<String>), String> { | ||
| let mut format = DeployOutputFormat::Human; | ||
| let mut workspace = env::current_dir().unwrap_or_else(|_| PathBuf::from(".")); | ||
| let mut service_filter = None; | ||
| let mut iter = args.iter().peekable(); | ||
|
|
||
| while let Some(arg) = iter.next() { | ||
| match arg.as_str() { | ||
| "--json" => format = DeployOutputFormat::Json, | ||
| "--workspace" => { | ||
| let value = iter | ||
| .next() | ||
| .ok_or_else(|| "missing value for --workspace".to_string())?; | ||
| workspace = PathBuf::from(value); | ||
| } | ||
| "--service" => { | ||
| let value = iter | ||
| .next() | ||
| .ok_or_else(|| "missing value for --service".to_string())?; | ||
| service_filter = Some(value.to_string()); | ||
| } | ||
| flag if flag.starts_with("--") => return Err(format!("unknown flag: {flag}")), | ||
| other => return Err(format!("unexpected argument: {other}")), | ||
| } | ||
| } | ||
|
|
||
| Ok((format, workspace, service_filter)) | ||
| } | ||
|
|
||
| fn print_human(workspace: &PathBuf, registry_exists: bool, services: &[ServiceRecord]) { | ||
| println!("Codra Deploy Status"); | ||
| println!(); | ||
| println!("Workspace: {}", workspace.display()); | ||
| println!("Registry: {}", crate::registry::services_registry_path(workspace).display()); | ||
| println!("Registry exists: {}", if registry_exists { "yes" } else { "no" }); | ||
| println!("Services: {}", services.len()); | ||
| println!(); | ||
|
|
||
| if services.is_empty() { | ||
| println!("No deployed services recorded yet."); | ||
| println!("Run `codra deploy up --execute` to create the first deployment record in a later PR."); | ||
| return; | ||
| } | ||
|
|
||
| for service in services { | ||
| println!("{} ({})", service.service_name, service.project); | ||
| println!(" Status: {:?}", service.status); | ||
| println!(" Container: {}", service.container_name); | ||
| println!(" Image: {}", service.image); | ||
| if let Some(host_port) = service.host_port { | ||
| println!(" Host port: {host_port}"); | ||
| } | ||
| if let Some(deploy_id) = &service.current_deploy_id { | ||
| println!(" Current deploy: {deploy_id}"); | ||
| } | ||
| if let Some(url) = &service.health_check_url { | ||
| println!(" Health URL: {url}"); | ||
| } else if let Some(path) = &service.health_check_path { | ||
| println!(" Health path: {path}"); | ||
| } | ||
| println!(" Updated: {}", service.updated_at); | ||
| println!(); | ||
| } | ||
| } | ||
|
|
||
| fn print_status_help() { | ||
| println!("codra deploy status [--workspace <path>] [--service <name>] [--json]"); | ||
| println!(" Show deployed services from the local .codra/deployments registry."); | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn parse_status_args_reads_workspace_service_and_json() { | ||
| let parsed = parse_args(&[ | ||
| "--workspace".to_string(), | ||
| "/tmp/workspace".to_string(), | ||
| "--service".to_string(), | ||
| "web".to_string(), | ||
| "--json".to_string(), | ||
| ]) | ||
| .expect("parse status args"); | ||
|
|
||
| assert_eq!(parsed.0, DeployOutputFormat::Json); | ||
| assert_eq!(parsed.1, PathBuf::from("/tmp/workspace")); | ||
| assert_eq!(parsed.2, Some("web".to_string())); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These dependencies were added without updating
Cargo.lock; the reviewed lockfile still has nocrosstermorratatuipackage entries. Sincecargo build --helpdefines--lockedas asserting thatCargo.lockremains unchanged, any locked/reproducible build of this repo will fail before compilation until the regenerated lockfile is committed with the manifest change.Useful? React with 👍 / 👎.