{"id":19689459,"url":"https://github.com/EmbarkStudios/krates","last_synced_at":"2025-04-29T08:35:17.655Z","repository":{"id":43637030,"uuid":"232534630","full_name":"EmbarkStudios/krates","owner":"EmbarkStudios","description":"📦 Creates graphs of crates from cargo metadata 🦀","archived":false,"fork":false,"pushed_at":"2025-02-27T06:57:52.000Z","size":875,"stargazers_count":59,"open_issues_count":2,"forks_count":19,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T09:17:04.993Z","etag":null,"topics":["crates","metadata","rust-library"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EmbarkStudios.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-08T10:09:32.000Z","updated_at":"2025-02-27T06:57:55.000Z","dependencies_parsed_at":"2024-01-12T14:24:52.497Z","dependency_job_id":"a909d47a-8204-4896-b1c7-3a731acbe7a7","html_url":"https://github.com/EmbarkStudios/krates","commit_stats":{"total_commits":107,"total_committers":7,"mean_commits":"15.285714285714286","dds":0.09345794392523366,"last_synced_commit":"a7c9e7c50e2f860b9142b982bca12a15bc03c684"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":"EmbarkStudios/opensource-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmbarkStudios%2Fkrates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmbarkStudios%2Fkrates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmbarkStudios%2Fkrates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmbarkStudios%2Fkrates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EmbarkStudios","download_url":"https://codeload.github.com/EmbarkStudios/krates/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251465290,"owners_count":21593854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crates","metadata","rust-library"],"created_at":"2024-11-11T19:00:55.736Z","updated_at":"2025-04-29T08:35:16.840Z","avatar_url":"https://github.com/EmbarkStudios.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# `📦 krates`\n\n[![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://embark.dev)\n[![Embark](https://img.shields.io/badge/discord-ark-%237289da.svg?logo=discord)](https://discord.gg/dAuKfZS)\n[![Crates.io](https://img.shields.io/crates/v/krates.svg)](https://crates.io/crates/krates)\n[![Docs](https://docs.rs/krates/badge.svg)](https://docs.rs/krates)\n[![dependency status](https://deps.rs/repo/github/EmbarkStudios/krates/status.svg)](https://deps.rs/repo/github/EmbarkStudios/krates)\n[![Build Status](https://github.com/EmbarkStudios/krates/workflows/CI/badge.svg)](https://github.com/EmbarkStudios/krates/actions?workflow=CI)\n\nCreates graphs of crates from [cargo_metadata](https://crates.io/crates/cargo_metadata) metadata.\n\n\u003c/div\u003e\n\n## Usage\n\n```rust\nuse krates::{Builder, Cmd, Krates, cm, petgraph};\nfn main() -\u003e Result\u003c(), krates::Error\u003e {\n    let mut cmd = Cmd::new();\n    cmd.manifest_path(\"path/to/a/Cargo.toml\");\n    // Enable all features, works for either an entire workspace or a single crate\n    cmd.all_features();\n\n    let mut builder = Builder::new();\n    // Let's filter out any crates that aren't used by x86_64 windows\n    builder.include_targets(std::iter::once((\"x86_64-pc-windows-msvc\", vec![])));\n\n    let krates: Krates = builder.build(cmd, |pkg: cm::Package| {\n        println!(\"Crate {} was filtered out\", pkg.id);\n    })?;\n\n    // Print a dot graph of the entire crate graph\n    println!(\"{:?}\", petgraph::dot::Dot::new(krates.graph()));\n\n    Ok(())\n}\n```\n\n`krates` can also be used if you use `cargo` as a dependency. It doesn't depend on `cargo` itself since cargo moves quickly and we don't want to artificially limit which versions you use, but, at least with the current stable `cargo` crate, the following code works well.\n\n```rust\nfn get_metadata(\n    no_default_features: bool,\n    all_features: bool,\n    features: Vec\u003cString\u003e,\n    manifest_path: PathBuf,\n) -\u003e Result\u003ckrates::cm::Metadata, anyhow::Error\u003e {\n    let config = cargo::util::Config::default()?;\n    let ws = cargo::core::Workspace::new(\u0026manifest_path, \u0026config)?;\n    let options = cargo::ops::OutputMetadataOptions {\n        features,\n        no_default_features,\n        all_features,\n        no_deps: false,\n        version: 1,\n        filter_platforms: vec![],\n    };\n\n    let md = cargo::ops::output_metadata(\u0026ws, \u0026options)?;\n    let md_value = serde_json::to_value(md)?;\n\n    Ok(serde_json::from_value(md_value)?)\n}\n```\n\n## Contributing\n\n[![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4-ff69b4.svg)](../CODE_OF_CONDUCT.md)\n\nWe welcome community contributions to this project.\n\nPlease read our [Contributor Guide](CONTRIBUTING.md) for more information on how to get started.\n\n## License\n\nLicensed under either of\n\n* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n* MIT license ([LICENSE-MIT](LICENSE-MIT) or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEmbarkStudios%2Fkrates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEmbarkStudios%2Fkrates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEmbarkStudios%2Fkrates/lists"}