@repokit/core 4.0.6 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -4
- package/dist/types.d.mts +1 -1
- package/externals/TSCompiler.ts +1 -2
- package/externals/types.ts +1 -1
- package/package.json +29 -19
- package/Cargo.lock +0 -1609
- package/Cargo.toml +0 -23
- package/installation/install.sh +0 -99
- package/internals/argv/argv.rs +0 -132
- package/internals/argv/mod.rs +0 -1
- package/internals/caches/crawl_cache.rs +0 -126
- package/internals/caches/file_cache.rs +0 -104
- package/internals/caches/mod.rs +0 -6
- package/internals/caches/old_cache.rs +0 -35
- package/internals/caches/repokit_version_resolver.rs +0 -50
- package/internals/caches/settings_cache.rs +0 -73
- package/internals/caches/version_cache.rs +0 -142
- package/internals/context/cache_scope.rs +0 -71
- package/internals/context/file_system.rs +0 -66
- package/internals/context/git_scope.rs +0 -55
- package/internals/context/mod.rs +0 -5
- package/internals/context/node_scope.rs +0 -133
- package/internals/context/typescript_bridge.rs +0 -84
- package/internals/executables/internal_executable.rs +0 -15
- package/internals/executables/internal_executable_definition.rs +0 -40
- package/internals/executables/mod.rs +0 -2
- package/internals/executor/executor.rs +0 -88
- package/internals/executor/mod.rs +0 -1
- package/internals/file_walker/file_walker.rs +0 -69
- package/internals/file_walker/mod.rs +0 -2
- package/internals/file_walker/walker.rs +0 -114
- package/internals/internal_commands/help.rs +0 -174
- package/internals/internal_commands/internal_registry.rs +0 -34
- package/internals/internal_commands/list_commands.rs +0 -97
- package/internals/internal_commands/list_owners.rs +0 -61
- package/internals/internal_commands/list_themes.rs +0 -114
- package/internals/internal_commands/list_version.rs +0 -59
- package/internals/internal_commands/locate_command.rs +0 -77
- package/internals/internal_commands/mod.rs +0 -11
- package/internals/internal_commands/onboarder.rs +0 -60
- package/internals/internal_commands/register_command.rs +0 -99
- package/internals/internal_commands/search_commands.rs +0 -201
- package/internals/internal_commands/upgrade_repokit.rs +0 -71
- package/internals/internal_filesystem/file_builder.rs +0 -56
- package/internals/internal_filesystem/mod.rs +0 -1
- package/internals/logger/logger.rs +0 -163
- package/internals/logger/mod.rs +0 -1
- package/internals/main.rs +0 -23
- package/internals/post_processing/mod.rs +0 -1
- package/internals/post_processing/post_processor.rs +0 -37
- package/internals/repokit/command_definition.rs +0 -11
- package/internals/repokit/mod.rs +0 -6
- package/internals/repokit/repokit.rs +0 -146
- package/internals/repokit/repokit_command.rs +0 -101
- package/internals/repokit/repokit_config.rs +0 -101
- package/internals/repokit/repokit_construct_validator.rs +0 -11
- package/internals/repokit/repokit_runtime.rs +0 -43
- package/internals/themes/built_in_themes/mod.rs +0 -3
- package/internals/themes/built_in_themes/money.rs +0 -41
- package/internals/themes/built_in_themes/seeing_red.rs +0 -41
- package/internals/themes/built_in_themes/the_blues.rs +0 -41
- package/internals/themes/mod.rs +0 -5
- package/internals/themes/theme.rs +0 -108
- package/internals/themes/theme_colors.rs +0 -32
- package/internals/themes/theme_inputs.rs +0 -35
- package/internals/themes/theme_registry.rs +0 -123
- package/internals/validations/command_validations.rs +0 -127
- package/internals/validations/mod.rs +0 -1
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
use std::sync::{LazyLock, Mutex, MutexGuard};
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
use crate::{
|
|
5
|
-
context::{
|
|
6
|
-
cache_scope::CacheScope, file_system::FileSystem, git_scope::GitScope,
|
|
7
|
-
node_scope::NodeScope, typescript_bridge::TypeScriptBridge,
|
|
8
|
-
},
|
|
9
|
-
repokit::repokit_config::RepoKitConfig,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
pub struct RepoKitRuntime {
|
|
13
|
-
pub git: GitScope,
|
|
14
|
-
pub node: NodeScope,
|
|
15
|
-
pub files: FileSystem,
|
|
16
|
-
pub caches: CacheScope,
|
|
17
|
-
pub configuration: RepoKitConfig,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static REPOKIT_RUNTIME: LazyLock<Mutex<RepoKitRuntime>> =
|
|
21
|
-
LazyLock::new(|| Mutex::new(RepoKitRuntime::new()));
|
|
22
|
-
|
|
23
|
-
impl RepoKitRuntime {
|
|
24
|
-
pub fn new() -> RepoKitRuntime {
|
|
25
|
-
let git = GitScope::new();
|
|
26
|
-
let files = FileSystem::new(&git.root);
|
|
27
|
-
let caches = CacheScope::new(&git, &files);
|
|
28
|
-
let mut node = NodeScope::new(&git.root);
|
|
29
|
-
let configuration = TypeScriptBridge::parse_configuration(&files, &mut node);
|
|
30
|
-
RepoKitRuntime {
|
|
31
|
-
git,
|
|
32
|
-
node,
|
|
33
|
-
files,
|
|
34
|
-
caches,
|
|
35
|
-
configuration,
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
pub fn with_runtime<R>(mut func: impl FnMut(MutexGuard<'_, RepoKitRuntime>) -> R) -> R {
|
|
40
|
-
let registry = REPOKIT_RUNTIME.lock().unwrap();
|
|
41
|
-
func(registry)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
use colored::Color;
|
|
2
|
-
|
|
3
|
-
use crate::themes::theme_colors::ThemeColors;
|
|
4
|
-
|
|
5
|
-
pub const MONEY: ThemeColors = ThemeColors {
|
|
6
|
-
prefixColor: Color::TrueColor {
|
|
7
|
-
r: 26,
|
|
8
|
-
g: 227,
|
|
9
|
-
b: 133,
|
|
10
|
-
},
|
|
11
|
-
commandColor: Color::TrueColor {
|
|
12
|
-
r: 82,
|
|
13
|
-
g: 234,
|
|
14
|
-
b: 74,
|
|
15
|
-
},
|
|
16
|
-
subcommandColor: Color::TrueColor {
|
|
17
|
-
r: 51,
|
|
18
|
-
g: 241,
|
|
19
|
-
b: 162,
|
|
20
|
-
},
|
|
21
|
-
argColor: Color::TrueColor {
|
|
22
|
-
r: 124,
|
|
23
|
-
g: 244,
|
|
24
|
-
b: 102,
|
|
25
|
-
},
|
|
26
|
-
descriptionColor: Color::TrueColor {
|
|
27
|
-
r: 126,
|
|
28
|
-
g: 168,
|
|
29
|
-
b: 140,
|
|
30
|
-
},
|
|
31
|
-
errorPrefixColor: Color::TrueColor {
|
|
32
|
-
r: 220,
|
|
33
|
-
g: 36,
|
|
34
|
-
b: 100,
|
|
35
|
-
},
|
|
36
|
-
highlightColor: Color::TrueColor {
|
|
37
|
-
r: 25,
|
|
38
|
-
g: 206,
|
|
39
|
-
b: 91,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
use colored::Color;
|
|
2
|
-
|
|
3
|
-
use crate::themes::theme_colors::ThemeColors;
|
|
4
|
-
|
|
5
|
-
pub const SEEING_RED: ThemeColors = ThemeColors {
|
|
6
|
-
prefixColor: Color::TrueColor {
|
|
7
|
-
r: 220,
|
|
8
|
-
g: 36,
|
|
9
|
-
b: 91,
|
|
10
|
-
},
|
|
11
|
-
commandColor: Color::TrueColor {
|
|
12
|
-
r: 220,
|
|
13
|
-
g: 36,
|
|
14
|
-
b: 36,
|
|
15
|
-
},
|
|
16
|
-
subcommandColor: Color::TrueColor {
|
|
17
|
-
r: 220,
|
|
18
|
-
g: 131,
|
|
19
|
-
b: 36,
|
|
20
|
-
},
|
|
21
|
-
argColor: Color::TrueColor {
|
|
22
|
-
r: 220,
|
|
23
|
-
g: 205,
|
|
24
|
-
b: 36,
|
|
25
|
-
},
|
|
26
|
-
descriptionColor: Color::TrueColor {
|
|
27
|
-
r: 179,
|
|
28
|
-
g: 100,
|
|
29
|
-
b: 151,
|
|
30
|
-
},
|
|
31
|
-
errorPrefixColor: Color::TrueColor {
|
|
32
|
-
r: 220,
|
|
33
|
-
g: 36,
|
|
34
|
-
b: 39,
|
|
35
|
-
},
|
|
36
|
-
highlightColor: Color::TrueColor {
|
|
37
|
-
r: 237,
|
|
38
|
-
g: 175,
|
|
39
|
-
b: 41,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
use colored::Color;
|
|
2
|
-
|
|
3
|
-
use crate::themes::theme_colors::ThemeColors;
|
|
4
|
-
|
|
5
|
-
pub const THE_BLUES: ThemeColors = ThemeColors {
|
|
6
|
-
prefixColor: Color::TrueColor {
|
|
7
|
-
r: 36,
|
|
8
|
-
g: 111,
|
|
9
|
-
b: 255,
|
|
10
|
-
},
|
|
11
|
-
commandColor: Color::TrueColor {
|
|
12
|
-
r: 52,
|
|
13
|
-
g: 96,
|
|
14
|
-
b: 255,
|
|
15
|
-
},
|
|
16
|
-
subcommandColor: Color::TrueColor {
|
|
17
|
-
r: 0,
|
|
18
|
-
g: 157,
|
|
19
|
-
b: 255,
|
|
20
|
-
},
|
|
21
|
-
argColor: Color::TrueColor {
|
|
22
|
-
r: 40,
|
|
23
|
-
g: 175,
|
|
24
|
-
b: 253,
|
|
25
|
-
},
|
|
26
|
-
descriptionColor: Color::TrueColor {
|
|
27
|
-
r: 100,
|
|
28
|
-
g: 165,
|
|
29
|
-
b: 179,
|
|
30
|
-
},
|
|
31
|
-
errorPrefixColor: Color::TrueColor {
|
|
32
|
-
r: 220,
|
|
33
|
-
g: 36,
|
|
34
|
-
b: 100,
|
|
35
|
-
},
|
|
36
|
-
highlightColor: Color::TrueColor {
|
|
37
|
-
r: 69,
|
|
38
|
-
g: 219,
|
|
39
|
-
b: 229,
|
|
40
|
-
},
|
|
41
|
-
};
|
package/internals/themes/mod.rs
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
use colored::{Color, ColoredString, Colorize};
|
|
2
|
-
|
|
3
|
-
use crate::themes::{
|
|
4
|
-
theme_colors::ThemeColors,
|
|
5
|
-
theme_inputs::{RepoKitTheme, ThemeInput, ThemeInputColors},
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
#[derive(Clone)]
|
|
9
|
-
pub struct Theme {
|
|
10
|
-
pub name: String,
|
|
11
|
-
pub colors: ThemeColors,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
impl Theme {
|
|
15
|
-
pub fn new(input: ThemeInput) -> Theme {
|
|
16
|
-
Theme {
|
|
17
|
-
name: input.name,
|
|
18
|
-
colors: ThemeColors {
|
|
19
|
-
prefixColor: input.colors.prefixColor.unwrap_or(Color::BrightMagenta),
|
|
20
|
-
commandColor: input.colors.commandColor.unwrap_or(Color::BrightBlue),
|
|
21
|
-
subcommandColor: input.colors.subcommandColor.unwrap_or(Color::TrueColor {
|
|
22
|
-
r: 175,
|
|
23
|
-
g: 247,
|
|
24
|
-
b: 7,
|
|
25
|
-
}),
|
|
26
|
-
argColor: input.colors.argColor.unwrap_or(Color::Green),
|
|
27
|
-
descriptionColor: input.colors.descriptionColor.unwrap_or(Color::TrueColor {
|
|
28
|
-
r: 128,
|
|
29
|
-
g: 128,
|
|
30
|
-
b: 128,
|
|
31
|
-
}),
|
|
32
|
-
errorPrefixColor: input.colors.errorPrefixColor.unwrap_or(Color::Red),
|
|
33
|
-
highlightColor: input.colors.highlightColor.unwrap_or(Color::BrightBlue),
|
|
34
|
-
},
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
pub fn prefix(&self, msg: &str) -> ColoredString {
|
|
39
|
-
msg.color(self.colors.prefixColor).bold()
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
pub fn command(&self, msg: &str) -> ColoredString {
|
|
43
|
-
msg.color(self.colors.commandColor)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
pub fn sub_command(&self, msg: &str) -> ColoredString {
|
|
47
|
-
msg.color(self.colors.subcommandColor)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
pub fn arg(&self, msg: &str) -> ColoredString {
|
|
51
|
-
msg.color(self.colors.argColor)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
pub fn description(&self, msg: &str) -> ColoredString {
|
|
55
|
-
msg.color(self.colors.descriptionColor)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
pub fn error_prefix(&self, msg: &str) -> ColoredString {
|
|
59
|
-
msg.color(self.colors.errorPrefixColor).bold()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
pub fn highlight(&self, msg: &str) -> ColoredString {
|
|
63
|
-
msg.color(self.colors.highlightColor)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
pub fn from_configuration(theme: &RepoKitTheme) -> Theme {
|
|
67
|
-
Theme::new(ThemeInput {
|
|
68
|
-
name: theme.name.clone(),
|
|
69
|
-
colors: ThemeInputColors {
|
|
70
|
-
prefixColor: Theme::parse_rgb(&theme.colors.prefixColor),
|
|
71
|
-
commandColor: Theme::parse_rgb(&theme.colors.commandColor),
|
|
72
|
-
subcommandColor: Theme::parse_rgb(&theme.colors.subcommandColor),
|
|
73
|
-
argColor: Theme::parse_rgb(&theme.colors.argColor),
|
|
74
|
-
descriptionColor: Theme::parse_rgb(&theme.colors.descriptionColor),
|
|
75
|
-
errorPrefixColor: Theme::parse_rgb(&theme.colors.errorPrefixColor),
|
|
76
|
-
highlightColor: Theme::parse_rgb(&theme.colors.highlightColor),
|
|
77
|
-
},
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
fn parse_rgb(rgb_str: &Option<String>) -> Option<Color> {
|
|
82
|
-
match rgb_str {
|
|
83
|
-
Some(rgb) => {
|
|
84
|
-
let trimmed = rgb
|
|
85
|
-
.strip_prefix("rgb(")
|
|
86
|
-
.and_then(|s| s.strip_suffix(')'))
|
|
87
|
-
.map(|s| s.trim())?;
|
|
88
|
-
|
|
89
|
-
// 2. Split the remaining string by commas.
|
|
90
|
-
let parts: Vec<&str> = trimmed.split(',').collect();
|
|
91
|
-
|
|
92
|
-
if parts.len() == 3 {
|
|
93
|
-
// 3. Trim whitespace from each part and parse to a u8.
|
|
94
|
-
// `.parse()` returns a `Result`, so we use `.ok()` to convert to an `Option`,
|
|
95
|
-
// and the `?` operator to return early if any parse fails.
|
|
96
|
-
let r = parts[0].trim().parse::<u8>().ok()?;
|
|
97
|
-
let g = parts[1].trim().parse::<u8>().ok()?;
|
|
98
|
-
let b = parts[2].trim().parse::<u8>().ok()?;
|
|
99
|
-
|
|
100
|
-
Some(Color::TrueColor { r, g, b })
|
|
101
|
-
} else {
|
|
102
|
-
None
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
None => None,
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
use colored::Color;
|
|
2
|
-
|
|
3
|
-
use crate::themes::theme_inputs::ThemeInputColors;
|
|
4
|
-
|
|
5
|
-
#[derive(Clone)]
|
|
6
|
-
pub struct ThemeColors {
|
|
7
|
-
pub prefixColor: Color,
|
|
8
|
-
pub commandColor: Color,
|
|
9
|
-
pub subcommandColor: Color,
|
|
10
|
-
pub argColor: Color,
|
|
11
|
-
pub descriptionColor: Color,
|
|
12
|
-
pub errorPrefixColor: Color,
|
|
13
|
-
pub highlightColor: Color,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
impl ThemeColors {
|
|
17
|
-
pub fn from_options(input: ThemeInputColors) -> ThemeColors {
|
|
18
|
-
ThemeColors {
|
|
19
|
-
prefixColor: input.prefixColor.unwrap_or(Color::BrightMagenta),
|
|
20
|
-
commandColor: input.commandColor.unwrap_or(Color::BrightBlue),
|
|
21
|
-
subcommandColor: input.subcommandColor.unwrap_or(Color::BrightCyan),
|
|
22
|
-
argColor: input.argColor.unwrap_or(Color::Green),
|
|
23
|
-
descriptionColor: input.descriptionColor.unwrap_or(Color::TrueColor {
|
|
24
|
-
r: 128,
|
|
25
|
-
g: 128,
|
|
26
|
-
b: 128,
|
|
27
|
-
}),
|
|
28
|
-
errorPrefixColor: input.errorPrefixColor.unwrap_or(Color::Red),
|
|
29
|
-
highlightColor: input.highlightColor.unwrap_or(Color::BrightBlue),
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
use colored::Color;
|
|
2
|
-
use schemars::JsonSchema;
|
|
3
|
-
use serde::Deserialize;
|
|
4
|
-
|
|
5
|
-
pub struct ThemeInputColors {
|
|
6
|
-
pub prefixColor: Option<Color>,
|
|
7
|
-
pub commandColor: Option<Color>,
|
|
8
|
-
pub subcommandColor: Option<Color>,
|
|
9
|
-
pub argColor: Option<Color>,
|
|
10
|
-
pub descriptionColor: Option<Color>,
|
|
11
|
-
pub errorPrefixColor: Option<Color>,
|
|
12
|
-
pub highlightColor: Option<Color>,
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
pub struct ThemeInput {
|
|
16
|
-
pub name: String,
|
|
17
|
-
pub colors: ThemeInputColors,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
#[derive(Debug, Deserialize, Clone, JsonSchema)]
|
|
21
|
-
pub struct RepoKitThemeColors {
|
|
22
|
-
pub prefixColor: Option<String>,
|
|
23
|
-
pub commandColor: Option<String>,
|
|
24
|
-
pub subcommandColor: Option<String>,
|
|
25
|
-
pub argColor: Option<String>,
|
|
26
|
-
pub descriptionColor: Option<String>,
|
|
27
|
-
pub errorPrefixColor: Option<String>,
|
|
28
|
-
pub highlightColor: Option<String>,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
#[derive(Debug, Deserialize, Clone, JsonSchema)]
|
|
32
|
-
pub struct RepoKitTheme {
|
|
33
|
-
pub name: String,
|
|
34
|
-
pub colors: RepoKitThemeColors,
|
|
35
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
use std::collections::HashMap;
|
|
2
|
-
|
|
3
|
-
use crate::themes::{
|
|
4
|
-
built_in_themes::{money::MONEY, seeing_red::SEEING_RED, the_blues::THE_BLUES},
|
|
5
|
-
theme::Theme,
|
|
6
|
-
theme_colors::ThemeColors,
|
|
7
|
-
theme_inputs::{RepoKitTheme, ThemeInputColors},
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
pub struct ThemeRegistry {
|
|
11
|
-
pub theme: String,
|
|
12
|
-
pub default_theme: String,
|
|
13
|
-
pub themes: HashMap<String, Theme>,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
impl ThemeRegistry {
|
|
17
|
-
pub fn new() -> ThemeRegistry {
|
|
18
|
-
let (default_theme_name, built_in_themes) = ThemeRegistry::built_in_themes();
|
|
19
|
-
ThemeRegistry {
|
|
20
|
-
themes: HashMap::from(built_in_themes),
|
|
21
|
-
theme: default_theme_name.to_string(),
|
|
22
|
-
default_theme: default_theme_name.to_string(),
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
pub fn set_theme(&mut self, theme: &str) -> bool {
|
|
27
|
-
if self.themes.contains_key(theme) && self.theme != theme {
|
|
28
|
-
self.theme = theme.to_string();
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
false
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
pub fn current_theme(&self) -> &Theme {
|
|
35
|
-
if self.themes.contains_key(&self.theme) {
|
|
36
|
-
return self
|
|
37
|
-
.themes
|
|
38
|
-
.get(&self.theme)
|
|
39
|
-
.expect("the current theme was not found");
|
|
40
|
-
}
|
|
41
|
-
self.themes
|
|
42
|
-
.get(&self.default_theme)
|
|
43
|
-
.expect("default theme should always exist")
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
pub fn register_user_theme(&mut self, theme: &RepoKitTheme) {
|
|
47
|
-
if self.themes.contains_key(&theme.name) {
|
|
48
|
-
self.on_naming_conflict(&theme.name);
|
|
49
|
-
}
|
|
50
|
-
self.themes
|
|
51
|
-
.insert(theme.name.clone(), Theme::from_configuration(theme));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
pub fn register_theme(&mut self, theme: Theme) {
|
|
55
|
-
let name = theme.name.clone();
|
|
56
|
-
self.themes.insert(name, theme);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
pub fn has(&self, theme: &str) -> bool {
|
|
60
|
-
self.themes.contains_key(theme)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
fn built_in_themes() -> (String, [(String, Theme); 4]) {
|
|
64
|
-
let (default_theme_name, built_in_color_schemes) = ThemeRegistry::built_in_color_schemes();
|
|
65
|
-
(
|
|
66
|
-
default_theme_name,
|
|
67
|
-
built_in_color_schemes.map(|(name, colors)| {
|
|
68
|
-
(
|
|
69
|
-
name.to_string(),
|
|
70
|
-
Theme {
|
|
71
|
-
colors,
|
|
72
|
-
name: name.to_string(),
|
|
73
|
-
},
|
|
74
|
-
)
|
|
75
|
-
}),
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
fn built_in_color_schemes() -> (String, [(&'static str, ThemeColors); 4]) {
|
|
80
|
-
let default_theme_name = "default";
|
|
81
|
-
(
|
|
82
|
-
default_theme_name.to_string(),
|
|
83
|
-
[
|
|
84
|
-
(default_theme_name, ThemeRegistry::create_default()),
|
|
85
|
-
("seeing-red", SEEING_RED),
|
|
86
|
-
("the-blues", THE_BLUES),
|
|
87
|
-
("money", MONEY),
|
|
88
|
-
],
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
fn create_default() -> ThemeColors {
|
|
93
|
-
ThemeColors::from_options(ThemeInputColors {
|
|
94
|
-
prefixColor: None,
|
|
95
|
-
commandColor: None,
|
|
96
|
-
subcommandColor: None,
|
|
97
|
-
argColor: None,
|
|
98
|
-
descriptionColor: None,
|
|
99
|
-
errorPrefixColor: None,
|
|
100
|
-
highlightColor: None,
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
fn on_naming_conflict(&self, name: &str) {
|
|
105
|
-
if ThemeRegistry::built_in_color_schemes()
|
|
106
|
-
.1
|
|
107
|
-
.map(|t| t.0)
|
|
108
|
-
.contains(&name)
|
|
109
|
-
{
|
|
110
|
-
println!(
|
|
111
|
-
"{}: I've discovered a theme that conflicts with one of my iternals. Please rename your {} theme",
|
|
112
|
-
self.current_theme().error_prefix("RepoKit"),
|
|
113
|
-
self.current_theme().highlight(name)
|
|
114
|
-
)
|
|
115
|
-
} else {
|
|
116
|
-
println!(
|
|
117
|
-
"{}: I've discovered two themes with the name {}. Please rename one of them",
|
|
118
|
-
self.current_theme().error_prefix("RepoKit"),
|
|
119
|
-
self.current_theme().highlight(name)
|
|
120
|
-
)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
use std::collections::HashMap;
|
|
2
|
-
|
|
3
|
-
use crate::{
|
|
4
|
-
context::typescript_bridge::TypeScriptBridge,
|
|
5
|
-
executables::internal_executable::InternalExecutable,
|
|
6
|
-
file_walker::file_walker::FileWalker,
|
|
7
|
-
internal_commands::internal_registry::InternalCommandRegistry,
|
|
8
|
-
logger::logger::Logger,
|
|
9
|
-
repokit::{repokit_command::RepoKitCommand, repokit_runtime::RepoKitRuntime},
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
pub struct CommandValidations;
|
|
13
|
-
|
|
14
|
-
impl CommandValidations {
|
|
15
|
-
pub fn collect_and_validate_internals() -> HashMap<String, Box<dyn InternalExecutable>> {
|
|
16
|
-
let internals = InternalCommandRegistry::new().get_all();
|
|
17
|
-
CommandValidations::detect_collisions_between_internals_and_root_commands(&internals);
|
|
18
|
-
internals
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
pub fn collect_and_validate_externals() -> HashMap<String, RepoKitCommand> {
|
|
22
|
-
let walker = FileWalker::new();
|
|
23
|
-
let result = walker.get();
|
|
24
|
-
let externals = TypeScriptBridge::parse_commands(&result);
|
|
25
|
-
let all = RepoKitRuntime::with_runtime(|runtime| {
|
|
26
|
-
[&externals[..], &runtime.configuration.thirdParty[..]].concat()
|
|
27
|
-
});
|
|
28
|
-
CommandValidations::detect_collisions_between_root_commands_and_externals(&all)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
pub fn detect_collisions_between_internals_and_externals(
|
|
32
|
-
internals: &HashMap<String, Box<dyn InternalExecutable>>,
|
|
33
|
-
externals: &HashMap<String, RepoKitCommand>,
|
|
34
|
-
) {
|
|
35
|
-
for (name, command) in externals {
|
|
36
|
-
if internals.contains_key(name) {
|
|
37
|
-
Logger::info(
|
|
38
|
-
format!(
|
|
39
|
-
"I encountered a command named {} that conflicts with one of my internals",
|
|
40
|
-
Logger::with_theme(|theme| theme.highlight(name)),
|
|
41
|
-
)
|
|
42
|
-
.as_str(),
|
|
43
|
-
);
|
|
44
|
-
Logger::info("Here's where it's located:");
|
|
45
|
-
Logger::log_file_path(&command.location);
|
|
46
|
-
Logger::exit_with_info("Please rename it");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
fn detect_collisions_between_internals_and_root_commands(
|
|
52
|
-
internals: &HashMap<String, Box<dyn InternalExecutable>>,
|
|
53
|
-
) {
|
|
54
|
-
for name in internals.keys() {
|
|
55
|
-
if RepoKitRuntime::with_runtime(|runtime| {
|
|
56
|
-
runtime.configuration.commands.contains_key(name)
|
|
57
|
-
}) {
|
|
58
|
-
Logger::info(
|
|
59
|
-
format!(
|
|
60
|
-
"I encountered a command named {} in your {} file that conflicts with one of my internals",
|
|
61
|
-
Logger::with_theme(|theme|theme.highlight(name)),
|
|
62
|
-
Logger::with_theme(|theme|theme.highlight("repokit.ts")),
|
|
63
|
-
)
|
|
64
|
-
.as_str(),
|
|
65
|
-
);
|
|
66
|
-
Logger::exit_with_info("Please rename it");
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
fn detect_collisions_between_root_commands_and_externals(
|
|
72
|
-
externals: &Vec<RepoKitCommand>,
|
|
73
|
-
) -> HashMap<String, RepoKitCommand> {
|
|
74
|
-
RepoKitRuntime::with_runtime(|runtime| {
|
|
75
|
-
let mut map: HashMap<String, RepoKitCommand> = HashMap::new();
|
|
76
|
-
for command in externals {
|
|
77
|
-
if map.contains_key(&command.name) {
|
|
78
|
-
let original = map.get(&command.name).expect("Unknown command");
|
|
79
|
-
CommandValidations::on_external_duplicate_collision(
|
|
80
|
-
command,
|
|
81
|
-
&original.location,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
map.insert(command.name.clone(), command.clone());
|
|
85
|
-
if runtime.configuration.commands.contains_key(&command.name) {
|
|
86
|
-
CommandValidations::on_external_root_collision(command);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
map
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
fn on_external_root_collision(command: &RepoKitCommand) {
|
|
94
|
-
Logger::info(format!(
|
|
95
|
-
"I encountered a package command named {} that conflicts with a command in your {} file",
|
|
96
|
-
Logger::with_theme(|theme|theme.highlight(&command.name)),
|
|
97
|
-
Logger::with_theme(|theme|theme.highlight("repokit.ts"))
|
|
98
|
-
)
|
|
99
|
-
.as_str(),
|
|
100
|
-
);
|
|
101
|
-
Logger::info("Here's where it's located:");
|
|
102
|
-
Logger::log_file_path(&command.location);
|
|
103
|
-
Logger::exit_with_info("Please rename one of these");
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
fn on_external_duplicate_collision(command: &RepoKitCommand, collision_path: &str) {
|
|
107
|
-
Logger::info(
|
|
108
|
-
format!(
|
|
109
|
-
"I encountered two packages with the name {}",
|
|
110
|
-
Logger::with_theme(|theme| theme.highlight(&command.name)),
|
|
111
|
-
)
|
|
112
|
-
.as_str(),
|
|
113
|
-
);
|
|
114
|
-
Logger::info("Here's where they're located:\n");
|
|
115
|
-
println!(
|
|
116
|
-
"{}1. {}",
|
|
117
|
-
Logger::indent(None),
|
|
118
|
-
Logger::with_theme(|theme| theme.highlight(collision_path))
|
|
119
|
-
);
|
|
120
|
-
println!(
|
|
121
|
-
"{}2. {}\n",
|
|
122
|
-
Logger::indent(None),
|
|
123
|
-
Logger::with_theme(|theme| theme.highlight(&command.location))
|
|
124
|
-
);
|
|
125
|
-
Logger::exit_with_info("Please rename one of these");
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pub mod command_validations;
|