Abbaye

at ccc40f5

//! # Abbaye
//!
//! ![logo](logo-wordmark.svg)
//!
//! Abbaye is a Static Site Generator (SSG) for your software. As GitHub,
//! Gitea, Forgejo and consorts offer, Abbaye can be used to generate a
//! website with your software's presentation, documentation, and distribution, per version.
//!
//! Here's an example file structure:
//!
//! ```text
//! .
//! ├── index.html # the main page of the website, enabling choosing a version, defaults to "latest" (contains a list of available versions and a iframe to the selected version?)
//! ├── releases.feed # the RSS feed of the releases
//! ├── latest -> v2.0.0 # symlink to the latest version (biggest version number)
//! ├── v1.0.0/ # the directory containing the version 1.0.0 of the software
//! │   ├── index.html # the main page of the version 1.0.0, from the README.md file.
//! │   │   # Contains a sidebar with links to the documentation and distribution.
//! │   │   # After the readme content, A changelog is displayed.
//! │   ├── docs/ # the directory containing the documentation of the version 1.0.0
//! │   │   ├── index.html # the main page of the documentation of the version 1.0.0
//! │   │   └── …
//! │   ├── docs.tar.gz # the tarball containing the documentation of the version 1.0.0
//! │   └── dist/ # the directory containing the distribution of the version 1.0.0
//! │       ├── source.tgz # the source code of the version 1.0.0
//! │       ├── mybin-v1.0.0-x86_64-unknown-linux-gnu
//! │       └── mybin-v1.0.0-x86_64-unknown-linux-musl
//! └── v2.0.0/ # the directory containing the version 2.0.0 of the software
//!     ├── index.html # the main page of the version 2.0.0
//!     ├── …
//!     └── …
//! ```
//!
//! ## Why the name "Abbaye"?
//!
//! An [Abbaye](https://en.wikipedia.org/wiki/Abbaye) is a French word for Abbey. An Abbey is a type of monastery, on the big-ish side, but still a small, quiet place.
//!
//! Anyway, that's where you store and display your relics (your software distribution).
//!
//! ## Installation
//!
//! ### Pre-built binaries
//!
//! You can grab a pre-built binary from the [releases page](http://vit.am/~ololduck/abbaye/latest).
//!
//! The `-musl` binaries are statically linked and should run everywhere, while the `-gnu` binaries are dynamically linked and require a compatible system library(which is probably available if you're not using an exotic distribution).
//!
//! ### From source
//!
//! To build from source, you need to have Rust installed. You can install Rust using [rustup](https://rustup.rs/).
//! If you don't have rust installed, this project won't be of much use to you, as it currently only implements rust builders :stuck_out_tongue:
//!
//! You can clone the [repository](https://sr.ht/~ololduck/abbaye) and build the project using `cargo build --release`.
//!
//! ## Usage
//!
//! Create a `abbaye.toml` configuration file in the root of your project. Here's an example configuration file to get you started:
//!
//! ```toml
//! [site]
//! name = "Abbaye"
//!
//! [version_extractor]
//! type = "git" # extract version from git tags
//! tag_prefix = "v"
//!
//! [changelog] # use the default changelog parser (Keepachangelog format in CHANGELOG.md)
//!
//! [[builders]]  # builds the project using cargo build --release
//! type = "cargo"
//! targets = ["x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl"]
//!
//! [[builders]]  # generates documentation using cargo doc
//! type = "cargo_doc"
//! no_deps = true  # Don't include dependencies in the documentation
//!
//! [[builders]]
//! type = "archive"  # creates a compressed tarball of the source code (can be of anything, really)
//! ```
//!
//! Then run `abbaye` to build the site. The site will be generated in the `public/` directory by default.
//! Now you can copy the contents of `public/` to your web server to deploy the site. For instance, with rsync:
//! `rsync --progress -avz --links --perms --update public/ ololduck@vit.am:public_html/abbaye/`

use miette::Result;

/// All builders for the site (ex: cargo build, cargo doc, etc.).
pub mod builders;
/// Parses the changelog file and generates a changelog page for the site.
pub mod changelog;
/// Handles the `abbaye.toml` configuration file.
pub mod config;
/// Generates the site from the configuration and builds it.
pub mod site;
/// Extracts current version information from different sources (ex: git tags, cargo metadata, etc.).
pub mod version_extractors;

#[tokio::main]
async fn main() -> Result<()> {
    tracing_subscriber::fmt()
        .with_timer(tracing_subscriber::fmt::time::SystemTime)
        .with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
        .init();

    let config = site::load_config()?;
    site::build_site(config).await
}