mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-26 10:21:53 +00:00
audit fixes, repo restructure, and documentation
Soundness and performance audit (17 fixes): - See AUDIT.md for full details and @claude comments in code Repo restructure: - Inline json-ptr and json-patch submodules as regular directories - Remove cbor submodule, replace serde_cbor with ciborium - Rename patch-db/ -> core/, patch-db-macro/ -> macro/, patch-db-macro-internals/ -> macro-internals/, patch-db-util/ -> util/ - Purge upstream CI/CD, bench, and release cruft from json-patch - Remove .gitmodules Test fixes: - Fix proptest doesnt_crash (unique file paths, proper close/cleanup) - Add PatchDb::close() for clean teardown Documentation: - Add README.md, ARCHITECTURE.md, CONTRIBUTING.md, CLAUDE.md, AUDIT.md - Add TSDocs to TypeScript client exports Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
12
util/Cargo.toml
Normal file
12
util/Cargo.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "patch-db-util"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
clap = "3.2.16"
|
||||
patch-db = { path = "../core", features = ["debug"] }
|
||||
serde_json = "1.0.85"
|
||||
tokio = { version = "1.20.1", features = ["full"] }
|
||||
43
util/src/main.rs
Normal file
43
util/src/main.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use patch_db::json_ptr::{JsonPointer, PtrSegment, ROOT};
|
||||
use serde_json::Value;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let mut app = clap::App::new("patch-db-util")
|
||||
.subcommand(
|
||||
clap::Command::new("dump").arg(
|
||||
clap::Arg::new("PATH")
|
||||
.required(true)
|
||||
.help("Path to the database file"),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
clap::Command::new("from-dump").arg(
|
||||
clap::Arg::new("PATH")
|
||||
.required(true)
|
||||
.help("Path to the database file"),
|
||||
),
|
||||
);
|
||||
|
||||
match app.clone().get_matches().subcommand() {
|
||||
Some(("dump", matches)) => {
|
||||
let path = matches.value_of("PATH").unwrap();
|
||||
let db = patch_db::PatchDb::open(path).await.unwrap();
|
||||
let dump = db.dump(&ROOT).await;
|
||||
serde_json::to_writer_pretty(&mut std::io::stdout(), &dump.value).unwrap();
|
||||
println!();
|
||||
}
|
||||
Some(("from-dump", matches)) => {
|
||||
let path = matches.value_of("PATH").unwrap();
|
||||
let value: Value = serde_json::from_reader(&mut std::io::stdin()).unwrap();
|
||||
let db = patch_db::PatchDb::open(path).await.unwrap();
|
||||
db.put(
|
||||
&JsonPointer::<&str, (&[PtrSegment], &[PtrSegment])>::default(),
|
||||
&value,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
_ => app.print_long_help().unwrap(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user