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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//! # `sublime_standard_tools`
//!
//! A comprehensive toolkit for working with Node.js projects from Rust applications.
//!
//! ## What
//! This crate provides a foundational set of utilities for interacting with Node.js
//! projects, package managers, and development workflows from Rust. It handles
//! project structure detection, command execution, environment management,
//! and various other tasks required when working with Node.js ecosystems.
//!
//! ## How
//! The crate follows a clean architectural approach with clear separation of concerns:
//!
//! ### Core Modules
//! - **`node`**: Generic Node.js concepts (repositories, package managers)
//! - **`project`**: Unified project detection and management
//! - **`monorepo`**: Monorepo-specific functionality and workspace management
//! - **`command`**: Robust command execution framework
//! - **`filesystem`**: Safe filesystem operations and path utilities
//! - **`error`**: Comprehensive error handling
//!
//! ### Architecture Overview
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ sublime_standard_tools │
//! ├─────────────────────────────────────────────────────────────┤
//! │ project/ │ Unified project detection and management │
//! │ ├─detector │ ├─ ProjectDetector (any project type) │
//! │ ├─manager │ ├─ ProjectManager (lifecycle management) │
//! │ └─types │ └─ ProjectInfo trait (common interface) │
//! ├─────────────────────────────────────────────────────────────┤
//! │ node/ │ Generic Node.js concepts │
//! │ ├─types │ ├─ RepoKind (Simple vs Monorepo) │
//! │ ├─package_* │ ├─ PackageManager & PackageManagerKind │
//! │ └─repository │ └─ RepositoryInfo trait │
//! ├─────────────────────────────────────────────────────────────┤
//! │ monorepo/ │ Monorepo-specific functionality │
//! │ ├─detector │ ├─ MonorepoDetector (workspace detection) │
//! │ ├─descriptor │ ├─ MonorepoDescriptor (full structure) │
//! │ └─kinds │ └─ MonorepoKind (npm, yarn, pnpm, etc.) │
//! ├─────────────────────────────────────────────────────────────┤
//! │ command/ │ Robust command execution │
//! │ filesystem/ │ Safe filesystem operations │
//! │ error/ │ Comprehensive error handling │
//! └─────────────────────────────────────────────────────────────┘
//! ```
//!
//! ## Why
//! Interacting with Node.js projects from Rust typically involves a significant
//! amount of boilerplate code for path handling, command execution, and project
//! structure detection. This crate abstracts these common tasks into a reusable
//! library with consistent error handling and cross-platform support.
//!
//! The new architecture provides:
//! - **Clean separation of concerns**: Each module has a clear responsibility
//! - **Unified project handling**: Works with both simple and monorepo projects
//! - **Type-safe abstractions**: Strong typing prevents common errors
//! - **Extensible design**: Easy to add new project types and package managers
//!
//! ## Quick Start
//!
//! ### Detect any Node.js project
//! ```ignore
//! use sublime_standard_tools::project::{ProjectDetector, ProjectDetectorTrait};
//! use std::path::Path;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let detector = ProjectDetector::new();
//!
//! match detector.detect(Path::new("."), None).await {
//! Ok(project) => {
//! let info = project.as_project_info();
//! println!("Found {} project", info.kind().name());
//!
//! if let Some(pm) = info.package_manager() {
//! println!("Using {} package manager", pm.command());
//! }
//! }
//! Err(e) => eprintln!("Detection failed: {}", e),
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ### Auto-load configuration from project files
//! All major components support automatic configuration loading:
//! ```rust
//! use sublime_standard_tools::{
//! project::ProjectDetector,
//! monorepo::MonorepoDetector,
//! filesystem::FileSystemManager,
//! command::DefaultCommandExecutor,
//! config::StandardConfig,
//! };
//! use std::path::Path;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Each component uses default config or accepts explicit configuration
//! let project_detector = ProjectDetector::new();
//! let monorepo_detector = MonorepoDetector::new(); // Uses default config
//! let filesystem = FileSystemManager::new(); // Uses default config
//! let executor = DefaultCommandExecutor::new(); // Uses default config
//!
//! // Or with explicit configuration
//! let config = StandardConfig::default();
//! let monorepo_detector_with_config = MonorepoDetector::new_with_config(config.monorepo);
//! # Ok(())
//! # }
//! ```
//!
//! ### Work with package managers
//! ```ignore
//! use sublime_standard_tools::node::{PackageManager, PackageManagerKind};
//! use std::path::Path;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Detect package manager
//! let manager = PackageManager::detect(Path::new(".")).await?;
//! println!("Using {}", manager.command());
//!
//! // Check capabilities
//! if manager.supports_workspaces() {
//! println!("Workspaces supported");
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ### Analyze monorepos
//! ```ignore
//! use sublime_standard_tools::monorepo::{MonorepoDetector, MonorepoDetectorTrait};
//! use std::path::Path;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let detector = MonorepoDetector::new();
//! if let Some(kind) = detector.is_monorepo_root(".").await? {
//! let monorepo = detector.detect_monorepo(".").await?;
//!
//! println!("Found {} with {} packages",
//! monorepo.kind().name(),
//! monorepo.packages().len());
//!
//! // Analyze dependencies
//! let graph = monorepo.get_dependency_graph();
//! for (pkg, deps) in graph {
//! println!("{} has {} dependents", pkg, deps.len());
//! }
//! }
//! # Ok(())
//! # }
//! ```
/// Version of the crate
pub const VERSION: &str = env!;
/// Returns the version of the crate