Skip to content

Commit

Permalink
feat: allow rust project to override the environment file path
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstevens19 committed Oct 15, 2024
1 parent fbf6939 commit c281cf6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/src/generator/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ serde = {{ version = "1.0.194", features = ["derive"] }}
let manifest_path = path.join("rindexer.yaml");
let result = start_rindexer(StartDetails {
manifest_path: &manifest_path,
override_environment_path: None,
indexing_details: if enable_indexer {
Some(IndexingDetails {
registry: register_all_handlers(&manifest_path).await,
Expand Down
4 changes: 4 additions & 0 deletions core/src/indexer/no_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ pub async fn setup_no_code(
if !details.indexing_details.enabled {
return Ok(StartDetails {
manifest_path: details.manifest_path,
// TODO: enable ability to override this for no-code projects
override_environment_path: None,
indexing_details: None,
graphql_details: details.graphql_details,
});
Expand Down Expand Up @@ -115,6 +117,8 @@ pub async fn setup_no_code(

Ok(StartDetails {
manifest_path: details.manifest_path,
// TODO: enable ability to override this for no-code projects
override_environment_path: None,
indexing_details: Some(IndexingDetails { registry }),
graphql_details: details.graphql_details,
})
Expand Down
5 changes: 4 additions & 1 deletion core/src/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct IndexingDetails {

pub struct StartDetails<'a> {
pub manifest_path: &'a PathBuf,
pub override_environment_path: Option<&'a PathBuf>,
pub indexing_details: Option<IndexingDetails>,
pub graphql_details: GraphqlOverrideSettings,
}
Expand Down Expand Up @@ -78,7 +79,9 @@ pub async fn start_rindexer(details: StartDetails<'_>) -> Result<(), StartRindex
let project_path = details.manifest_path.parent();
match project_path {
Some(project_path) => {
load_env_from_path(project_path);
let env_path =
details.override_environment_path.map(PathBuf::as_path).unwrap_or(project_path);
load_env_from_path(env_path);
let manifest = Arc::new(read_manifest(details.manifest_path)?);

if manifest.project_type != ProjectType::NoCode {
Expand Down
1 change: 1 addition & 0 deletions documentation/docs/pages/docs/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- feat: expose postgres ToSql trait
- feat: support with_transaction in postgres client
- feat: get the block timestamp from the RPC call (its an option as not all providers expose it)
- feat: allow rust project to override the environment file path

### Bug fixes
-------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ async fn main() {
let manifest_path = path.join("rindexer.yaml");
let result = start_rindexer(StartDetails {
manifest_path: &manifest_path,
override_environment_path: None,
indexing_details: if enable_indexer {
Some(IndexingDetails {
registry: register_all_handlers(&manifest_path).await,
Expand Down
1 change: 1 addition & 0 deletions rindexer_rust_playground/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async fn main() {
let manifest_path = path.join("rindexer.yaml");
let result = start_rindexer(StartDetails {
manifest_path: &manifest_path,
override_environment_path: None,
indexing_details: if enable_indexer {
// EventCallbackRegistry { events: vec![] }
Some(IndexingDetails { registry: register_all_handlers(&manifest_path).await })
Expand Down

0 comments on commit c281cf6

Please sign in to comment.