mario-eth / soldeer

Solidity Package Manager written in rust
MIT License
241 stars 26 forks source link

Remove global state #155

Closed DaniPopes closed 1 month ago

DaniPopes commented 3 months ago

Currently lots of assumptions are made about CWD, dependencies directory, ... due to heavy usage of global Lazy statics and getter functions which have no state, meaning none of these variables are configurable.

Random example 1: deep in "health check" is usage of global DEPENDENCY_DIR https://github.com/mario-eth/soldeer/blob/b31317860b576d40fa72df4ee52c969e2d65d02d/src/janitor.rs#L24

Random example 2: utils::get_base_url has to use an environment variable to override the value on cfg(test) https://github.com/mario-eth/soldeer/blob/660b6c95e33965e532dabedce30d0e48c5d174bc/src/utils.rs#L89-L95


An example fix would be something like struct Project or whatever you want to call it (like Rust crate) that contains dependency_dir: PathBuf, and these global functions are instead methods on this struct.

There are more ways to do this, but the main point is removing the global state to make it configurable.

mario-eth commented 3 months ago

We have version 0.4.0 on the making which takes care of all of these lazy and more modular. But we are releasing slowly. This release aimed sub-dependencies and an improved git support.

Version: 0.4.0 will have more improvements