1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
use std::path::{Path, PathBuf};
use anyhow::Result;
// REFACTOR: most of this impl is the same across all types
/// Configuration file for some component of the monorepo.
pub trait ConfigurationFile<T> {
/// Basename of the configuration file.
const FILENAME: &'static str;
/// Create an instance of this configuration file by reading
/// the specified file from this directory on disk.
fn from_directory(monorepo_root: &Path, directory: &Path) -> Result<T>;
/// Relative path to directory containing this configuration file,
/// from monorepo root.
fn directory(&self) -> PathBuf;
/// Relative path to this configuration file from the monorepo root.
fn path(&self) -> PathBuf;
/// Write this configuration file to disk.
fn write(&self) -> Result<()>;
}