Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 160 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 32 additions & 5 deletions cli/src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use rindexer::manifest::config::Config;
use rindexer::manifest::contract::ContractEvent;
#[cfg(feature = "reth")]
use rindexer::manifest::reth::RethConfig;
use rindexer::manifest::storage::ClickhouseDetails;
use rindexer::{
generator::{build::generate_rust_project, generate_docker_file},
manifest::{
Expand Down Expand Up @@ -153,11 +154,17 @@ pub fn handle_new_command(
let repository = prompt_for_optional_input::<String>("Repository", None);
let storage_choice = prompt_for_input_list(
"What Storages To Enable? (graphql can only be supported if postgres is enabled)",
&["postgres".to_string(), "csv".to_string(), "both".to_string(), "none".to_string()],
&[
"postgres".to_string(),
"clickhouse".to_string(),
"csv".to_string(),
"postgres and csv".to_string(),
"none".to_string(),
],
None,
);
let mut postgres_docker_enable = false;
if storage_choice == "postgres" || storage_choice == "both" {
if storage_choice == "postgres" || storage_choice == "postgres and csv" {
let postgres_docker = prompt_for_input_list(
"Postgres Docker Support Out The Box?",
&["yes".to_string(), "no".to_string()],
Expand All @@ -166,8 +173,9 @@ pub fn handle_new_command(
postgres_docker_enable = postgres_docker == "yes";
}

let postgres_enabled = storage_choice == "postgres" || storage_choice == "both";
let csv_enabled = storage_choice == "csv" || storage_choice == "both";
let postgres_enabled = storage_choice == "postgres" || storage_choice == "postgres and csv";
let csv_enabled = storage_choice == "csv" || storage_choice == "postgres and csv";
let clickhouse_enabled = storage_choice == "clickhouse";

// Handle Reth configuration if enabled
let final_reth_config = get_reth_config(reth_config);
Expand Down Expand Up @@ -255,9 +263,18 @@ pub fn handle_new_command(
postgres: if postgres_enabled {
Some(PostgresDetails {
enabled: true,
drop_each_run: None,
relationships: None,
indexes: None,
drop_each_run: None,
disable_create_tables: None,
})
} else {
None
},
clickhouse: if clickhouse_enabled {
Some(ClickhouseDetails {
enabled: true,
drop_each_run: None,
disable_create_tables: None,
})
} else {
Expand All @@ -279,6 +296,16 @@ pub fn handle_new_command(
// Write the rindexer.yaml file
write_manifest(&manifest, &rindexer_yaml_path)?;

// Write .env if required
if clickhouse_enabled {
let env = "CLICKHOUSE_URL=\nCLICKHOUSE_USER=\nCLICKHOUSE_PASSWORD=";

write_file(&project_path.join(".env"), env).map_err(|e| {
print_error_message(&format!("Failed to write .env file: {}", e));
e
})?;
}

// Write .env if required
if postgres_enabled {
if postgres_docker_enable {
Expand Down
2 changes: 2 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ reth-exex = { git = "https://github.com/paradigmxyz/reth", tag = "v1.5.0", featu
reth-node-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.5.0", optional = true }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.5.0", optional = true }
reth-tracing = { git = "https://github.com/paradigmxyz/reth", tag = "v1.5.0", optional = true }
async-std = "1.13.2"
clickhouse = { version = "0.13.3", features = ["chrono"] }

[target.'cfg(not(windows))'.dependencies]
rdkafka = { version = "0.37.0", features = ["tokio"] }
Expand Down
Loading
Loading