1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
extern crate self as fpm;

mod commands;
mod config;
mod dependency;
mod document;
mod font;
mod library;
mod snapshot;
mod tracker;
mod utils;

pub use commands::{
    build::build, diff::diff, mark::mark, status::status, sync::sync, tracks::tracks,
};
pub(crate) use config::Config;
pub(crate) use config::Package;
pub(crate) use dependency::Dependency;
pub(crate) use document::{process_dir, process_file, Document, FileFound, StaticAsset};
pub(crate) use font::Font;
pub(crate) use library::Library;
pub(crate) use snapshot::Snapshot;
pub(crate) use tracker::Track;
pub(crate) use utils::get_timestamp_nanosecond;

pub fn fpm_ftd() -> &'static str {
    include_str!("../fpm.ftd")
}

#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error("HttpError: {}", _0)]
    HttpError(#[from] reqwest::Error),

    #[error("IoError: {}", _0)]
    IoError(#[from] std::io::Error),

    #[error("IoError: {}", _0)]
    ZipError(#[from] zip::result::ZipError),

    #[error("FTDError: {}", _0)]
    FTDError(#[from] ftd::p1::Error),

    #[error("ConfigurationError: {message}")]
    ConfigurationError { message: String },
}

pub type Result<T> = std::result::Result<T, Error>;

pub fn ignore_history() -> Option<ignore::overrides::Override> {
    let mut overrides = ignore::overrides::OverrideBuilder::new("./");
    overrides.add("!.history").unwrap();
    overrides.add("!FPM").unwrap();
    overrides.build().ok()
}

#[cfg(test)]
mod tests {

    #[test]
    fn fbt() {
        if fbt_lib::main().is_some() {
            panic!("test failed")
        }
    }
}