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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! # Fabricatio Constants
//!
//! A foundational constants crate for the Fabricatio ecosystem, providing application-wide constants, paths, and configuration variables.
//!
//! This crate centralizes all constants used across the Fabricatio project, including application names, configuration file paths, directory locations, and environment variable names. It ensures consistency and provides a single source of truth for these values.
//!
//! ## Features
//!
//! - **Application Constants**: Centralized definitions for application name, repository details, and core package names
//! - **Path Management**: Automatic determination of user configuration directories across different operating systems
//! - **Template Support**: Constants for template directory management and global configuration files
//! - **Environment Variables**: Standardized names for configuration and logging variables
//!
//! ## Platform Support
//!
//! The crate automatically detects the user's operating system and provides appropriate paths:
//!
//! | Platform | Config Directory | Example |
//! |----------|------------------|----------|
//! | Linux | `$XDG_CONFIG_HOME` or `$HOME/.config` | `/home/alice/.config/fabricatio` |
//! | macOS | `$HOME/Library/Application Support` | `/Users/Alice/Library/Application Support/fabricatio` |
//! | Windows | `{FOLDERID_RoamingAppData}` | `C:\Users\Alice\AppData\Roaming\fabricatio` |
//!
//! ## Usage
//!
//! ```rust
//! use fabricatio_constants::{NAME, ROAMING, GLOBAL_CONFIG_FILE};
//!
//! fn main() {
//! println!("Application: {}", NAME);
//! println!("Config directory: {:?}", ROAMING);
//! println!("Config file: {:?}", GLOBAL_CONFIG_FILE);
//! }
//! ```
//!
//! For more information, see the [README](https://github.com/Whth/fabricatio/blob/main/crates/fabricatio-constants/README.md).
use BaseDirs;
use Lazy;
use PathBuf;
/// The application name used across the project.
pub const NAME: &str = "fabricatio";
/// The name of the core package used by the application.
pub const CORE_PACKAGE_NAME: &str = "fabricatio_core";
/// The default configuration file name used by the application.
pub const CONFIG_FILE: &str = "fabricatio.toml";
/// The GitHub repository owner for the application.
pub const REPO_OWNER: &str = "Whth";
/// The GitHub repository name for the application.
pub const REPO_NAME: &str = NAME;
/// Returns the path to the user's config directory based on the operating system.
///
/// |Platform | Value | Example |
/// | ------- | ------------------------------------- | -------------------------------- |
/// | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config/<APPNAME> | /home/alice/.config/app |
/// | macOS | `$HOME`/Library/Application Support/<APPNAME> | /Users/Alice/Library/Application Support/app |
/// | Windows | `{FOLDERID_RoamingAppData}\<APPNAME>` | C:\Users\Alice\AppData\Roaming\app |
///
/// # Arguments
/// * `app_name` - The name of the application used when constructing the directory path.
///
/// # Returns
/// An `Option<PathBuf>` representing the roaming directory if available.
/// A global static instance of the user's roaming configuration directory for the application.
pub static ROAMING: =
new;
/// The name of the templates' directory.
pub const TEMPLATES_DIRNAME: &str = "templates";
/// A global static instance of the templates directory located within the roaming configuration directory.
pub static TEMPLATES: = new;
/// A global static instance of the global configuration file path, constructed by joining
/// the roaming directory with the application-specific configuration file name.
pub static GLOBAL_CONFIG_FILE: = new;
/// The name of the logger variable used by the application.
pub const LOGGER_VARNAME: &str = "logger";
/// The name of the configuration variable used by the application.
pub const CONFIG_VARNAME: &str = "CONFIG";
/// The key used to store the Python source code path.
pub const PY_SOURCE_KEY: &str = "py_source";