-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathlib.rs
More file actions
153 lines (109 loc) · 4.68 KB
/
lib.rs
File metadata and controls
153 lines (109 loc) · 4.68 KB
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
use std::sync::Arc;
use std::{ffi::OsString, path::Path};
use petgraph::graph::NodeIndex;
use thiserror::Error;
use vite_path::AbsolutePath;
use vite_path::relative::InvalidPathDataError;
use vite_path::{AbsolutePathBuf, RelativePathBuf, absolute::StripPrefixError};
use vite_str::Str;
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
SqliteError(#[from] rusqlite::Error),
#[error(transparent)]
BincodeEncodeError(#[from] bincode::error::EncodeError),
#[error(transparent)]
BincodeDecodeError(#[from] bincode::error::DecodeError),
#[error("Unrecognized db version: {0}")]
UnrecognizedDbVersion(u32),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("IO error: {err} at {path:?}")]
IoWithPath { err: std::io::Error, path: Arc<AbsolutePath> },
#[error(transparent)]
JoinPathsError(#[from] std::env::JoinPathsError),
#[cfg(unix)]
#[error(transparent)]
NixError(#[from] nix::Error),
#[error(transparent)]
SerdeError(#[from] serde_json::Error),
#[error("Env value is not valid unicode: {key} = {value:?}")]
EnvValueIsNotValidUnicode { key: Str, value: OsString },
#[cfg(unix)]
#[error("Unsupported file type: {0:?}")]
UnsupportedFileType(nix::dir::Type),
#[error(transparent)]
Utf8Error(#[from] bstr::Utf8Error),
#[error(transparent)]
WaxBuildError(#[from] wax::BuildError),
#[error(transparent)]
WaxWalkError(#[from] wax::WalkError),
#[error("Duplicated task name: {0}")]
DuplicatedTask(Str),
#[error("Duplicated package name: {name} at {path1} and {path2}")]
DuplicatedPackageName { name: Str, path1: RelativePathBuf, path2: RelativePathBuf },
#[error("Circular dependency found : {0:?}")]
CycleDependenciesError(petgraph::algo::Cycle<NodeIndex>),
#[error("The package.json name is empty at {0:?}/package.json")]
EmptyPackageName(AbsolutePathBuf),
#[error("Package {0} not found in workspace")]
PackageNotFound(Str),
#[error("The package.json file is not found at {0:?}")]
PackageJsonNotFound(AbsolutePathBuf),
#[error("Task '{task_request}' not found in workspace")]
TaskNotFound { task_request: Str },
#[error("Dependency Task '{name}' not found in package located at {package_path}")]
TaskDependencyNotFound { name: Str, package_path: RelativePathBuf },
#[error("{task_request} should not contain multiple '#'")]
AmbiguousTaskRequest { task_request: Str },
#[error("Only one task request is allowed when running in implicit mode: {0}")]
OnlyOneTaskRequest(Str),
#[error("Recursive run is not allowed when task name contains '#': {0}")]
RecursiveRunWithScope(Str),
#[error(transparent)]
SerdeYmlError(#[from] serde_yml::Error),
#[error("Lint failed")]
LintFailed { status: Str, reason: Str },
#[error("Fmt failed")]
FmtFailed { status: Str, reason: Str },
#[error("Vite failed")]
ViteError { status: Str, reason: Str },
#[error("Test failed")]
TestFailed { status: Str, reason: Str },
#[error("Doc failed")]
DocFailed { status: Str, reason: Str },
#[error(
"The stripped path ({stripped_path:?}) is not a valid relative path because: {invalid_path_data_error}"
)]
StripPathError { stripped_path: Box<Path>, invalid_path_data_error: InvalidPathDataError },
#[error("The package at {package_path:?} is outside the workspace at {workspace_root:?}")]
PackageOutsideWorkspace { package_path: AbsolutePathBuf, workspace_root: AbsolutePathBuf },
#[error("Unsupported package manager: {0}")]
UnsupportedPackageManager(Str),
#[error("Unrecognized any package manager, please specify the package manager")]
UnrecognizedPackageManager,
#[error(
"Package manager {name}@{version} in {package_json_path:?} is invalid, expected format: 'package-manager-name@major.minor.patch'"
)]
PackageManagerVersionInvalid { name: Str, version: Str, package_json_path: AbsolutePathBuf },
#[error("Package manager {name}@{version} not found on {url}")]
PackageManagerVersionNotFound { name: Str, version: Str, url: Str },
#[error(transparent)]
SemverError(#[from] semver::Error),
#[error(transparent)]
ReqwestError(#[from] reqwest::Error),
#[error(transparent)]
JoinError(#[from] tokio::task::JoinError),
#[error("User cancelled by Ctrl+C")]
UserCancelled,
#[error(transparent)]
AnyhowError(#[from] anyhow::Error),
}
impl From<StripPrefixError<'_>> for Error {
fn from(value: StripPrefixError<'_>) -> Self {
Self::StripPathError {
stripped_path: Box::from(value.stripped_path),
invalid_path_data_error: value.invalid_path_data_error,
}
}
}