@repokit/core 2.1.0 → 3.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.
Files changed (41) hide show
  1. package/Cargo.lock +111 -5
  2. package/Cargo.toml +2 -1
  3. package/README.md +32 -25
  4. package/dist/RepoKitConfig.d.mts +2 -2
  5. package/dist/RepoKitConfig.mjs +3 -3
  6. package/dist/RepoKitTheme.d.mts +26 -26
  7. package/dist/RepoKitTheme.mjs +24 -24
  8. package/dist/index.d.mts +3 -4
  9. package/dist/index.mjs +1 -2
  10. package/dist/types.d.mts +16 -7
  11. package/externals/RepoKitConfig.ts +3 -3
  12. package/externals/RepoKitTheme.ts +26 -34
  13. package/externals/index.ts +0 -1
  14. package/externals/types.ts +20 -6
  15. package/installation/install.sh +9 -3
  16. package/internals/argv/argv.rs +133 -0
  17. package/internals/argv/mod.rs +1 -0
  18. package/internals/internal_commands/help.rs +6 -6
  19. package/internals/internal_commands/internal_registry.rs +5 -4
  20. package/internals/internal_commands/list_owners.rs +10 -10
  21. package/internals/internal_commands/list_themes.rs +113 -0
  22. package/internals/internal_commands/mod.rs +1 -0
  23. package/internals/internal_filesystem/internal_filesystem.rs +122 -1
  24. package/internals/logger/logger.rs +18 -1
  25. package/internals/main.rs +1 -0
  26. package/internals/repokit/interfaces.rs +2 -2
  27. package/internals/repokit/repokit.rs +5 -2
  28. package/internals/themes/built_in_themes/mod.rs +3 -0
  29. package/internals/themes/built_in_themes/money.rs +41 -0
  30. package/internals/themes/built_in_themes/seeing_red.rs +41 -0
  31. package/internals/themes/built_in_themes/the_blues.rs +41 -0
  32. package/internals/themes/mod.rs +3 -0
  33. package/internals/themes/theme.rs +48 -70
  34. package/internals/themes/theme_colors.rs +36 -0
  35. package/internals/themes/theme_inputs.rs +34 -0
  36. package/internals/themes/theme_registry.rs +80 -7
  37. package/media/list-themes.webp +0 -0
  38. package/package.json +2 -1
  39. package/dist/Themes.d.mts +0 -8
  40. package/dist/Themes.mjs +0 -31
  41. package/externals/Themes.ts +0 -31
@@ -0,0 +1,41 @@
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
+ };
@@ -1,2 +1,5 @@
1
+ pub mod built_in_themes;
1
2
  pub mod theme;
3
+ pub mod theme_colors;
4
+ pub mod theme_inputs;
2
5
  pub mod theme_registry;
@@ -1,63 +1,84 @@
1
1
  use colored::{Color, ColoredString, Colorize};
2
- use serde::Deserialize;
3
2
 
3
+ use crate::themes::{
4
+ theme_colors::ThemeColors,
5
+ theme_inputs::{RepoKitTheme, ThemeInput, ThemeInputColors},
6
+ };
7
+
8
+ #[derive(Clone)]
4
9
  pub struct Theme {
5
- prefixColor: Color,
6
- commandColor: Color,
7
- subcommandColor: Color,
8
- argColor: Color,
9
- descriptionColor: Color,
10
- errorPrefixColor: Color,
11
- highlightColor: Color,
10
+ pub name: String,
11
+ pub colors: ThemeColors,
12
12
  }
13
13
 
14
14
  impl Theme {
15
- pub fn new(colors: ThemeInputColors) -> Theme {
16
- Theme::from(colors)
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
+ }
17
36
  }
18
37
 
19
38
  pub fn prefix(&self, msg: &str) -> ColoredString {
20
- msg.color(self.prefixColor).bold()
39
+ msg.color(self.colors.prefixColor).bold()
21
40
  }
22
41
 
23
42
  pub fn command(&self, msg: &str) -> ColoredString {
24
- msg.color(self.commandColor)
43
+ msg.color(self.colors.commandColor)
25
44
  }
26
45
 
27
46
  pub fn sub_command(&self, msg: &str) -> ColoredString {
28
- msg.color(self.subcommandColor)
47
+ msg.color(self.colors.subcommandColor)
29
48
  }
30
49
 
31
50
  pub fn arg(&self, msg: &str) -> ColoredString {
32
- msg.color(self.argColor)
51
+ msg.color(self.colors.argColor)
33
52
  }
34
53
 
35
54
  pub fn description(&self, msg: &str) -> ColoredString {
36
- msg.color(self.descriptionColor)
55
+ msg.color(self.colors.descriptionColor)
37
56
  }
38
57
 
39
58
  pub fn error_prefix(&self, msg: &str) -> ColoredString {
40
- msg.color(self.errorPrefixColor).bold()
59
+ msg.color(self.colors.errorPrefixColor).bold()
41
60
  }
42
61
 
43
62
  pub fn highlight(&self, msg: &str) -> ColoredString {
44
- msg.color(self.highlightColor)
63
+ msg.color(self.colors.highlightColor)
45
64
  }
46
65
 
47
66
  pub fn from_configuration(theme: &RepoKitTheme) -> Theme {
48
- let copy = theme.clone();
49
- Theme::new(ThemeInputColors {
50
- prefixColor: Theme::parse_rgb(copy.prefixColor),
51
- commandColor: Theme::parse_rgb(copy.commandColor),
52
- subcommandColor: Theme::parse_rgb(copy.subcommandColor),
53
- argColor: Theme::parse_rgb(copy.argColor),
54
- descriptionColor: Theme::parse_rgb(copy.descriptionColor),
55
- errorPrefixColor: Theme::parse_rgb(copy.errorPrefixColor),
56
- highlightColor: Theme::parse_rgb(copy.highlightColor),
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
+ },
57
78
  })
58
79
  }
59
80
 
60
- fn parse_rgb(rgb_str: Option<String>) -> Option<Color> {
81
+ fn parse_rgb(rgb_str: &Option<String>) -> Option<Color> {
61
82
  match rgb_str {
62
83
  Some(rgb) => {
63
84
  let trimmed = rgb
@@ -85,46 +106,3 @@ impl Theme {
85
106
  }
86
107
  }
87
108
  }
88
-
89
- pub struct ThemeInputColors {
90
- pub prefixColor: Option<Color>,
91
- pub commandColor: Option<Color>,
92
- pub subcommandColor: Option<Color>,
93
- pub argColor: Option<Color>,
94
- pub descriptionColor: Option<Color>,
95
- pub errorPrefixColor: Option<Color>,
96
- pub highlightColor: Option<Color>,
97
- }
98
-
99
- impl From<ThemeInputColors> for Theme {
100
- fn from(input: ThemeInputColors) -> Theme {
101
- Theme {
102
- prefixColor: input.prefixColor.unwrap_or(Color::BrightMagenta),
103
- commandColor: input.commandColor.unwrap_or(Color::BrightBlue),
104
- subcommandColor: input.subcommandColor.unwrap_or(Color::TrueColor {
105
- r: 175,
106
- g: 247,
107
- b: 7,
108
- }),
109
- argColor: input.argColor.unwrap_or(Color::Green),
110
- descriptionColor: input.descriptionColor.unwrap_or(Color::TrueColor {
111
- r: 128,
112
- g: 128,
113
- b: 128,
114
- }),
115
- errorPrefixColor: input.errorPrefixColor.unwrap_or(Color::Red),
116
- highlightColor: input.highlightColor.unwrap_or(Color::BrightBlue),
117
- }
118
- }
119
- }
120
-
121
- #[derive(Debug, Deserialize, Clone)]
122
- pub struct RepoKitTheme {
123
- pub prefixColor: Option<String>,
124
- pub commandColor: Option<String>,
125
- pub subcommandColor: Option<String>,
126
- pub argColor: Option<String>,
127
- pub descriptionColor: Option<String>,
128
- pub errorPrefixColor: Option<String>,
129
- pub highlightColor: Option<String>,
130
- }
@@ -0,0 +1,36 @@
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::TrueColor {
22
+ r: 175,
23
+ g: 247,
24
+ b: 7,
25
+ }),
26
+ argColor: input.argColor.unwrap_or(Color::Green),
27
+ descriptionColor: input.descriptionColor.unwrap_or(Color::TrueColor {
28
+ r: 128,
29
+ g: 128,
30
+ b: 128,
31
+ }),
32
+ errorPrefixColor: input.errorPrefixColor.unwrap_or(Color::Red),
33
+ highlightColor: input.highlightColor.unwrap_or(Color::BrightBlue),
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,34 @@
1
+ use colored::Color;
2
+ use serde::Deserialize;
3
+
4
+ pub struct ThemeInputColors {
5
+ pub prefixColor: Option<Color>,
6
+ pub commandColor: Option<Color>,
7
+ pub subcommandColor: Option<Color>,
8
+ pub argColor: Option<Color>,
9
+ pub descriptionColor: Option<Color>,
10
+ pub errorPrefixColor: Option<Color>,
11
+ pub highlightColor: Option<Color>,
12
+ }
13
+
14
+ pub struct ThemeInput {
15
+ pub name: String,
16
+ pub colors: ThemeInputColors,
17
+ }
18
+
19
+ #[derive(Debug, Deserialize, Clone)]
20
+ pub struct RepoKitThemeColors {
21
+ pub prefixColor: Option<String>,
22
+ pub commandColor: Option<String>,
23
+ pub subcommandColor: Option<String>,
24
+ pub argColor: Option<String>,
25
+ pub descriptionColor: Option<String>,
26
+ pub errorPrefixColor: Option<String>,
27
+ pub highlightColor: Option<String>,
28
+ }
29
+
30
+ #[derive(Debug, Deserialize, Clone)]
31
+ pub struct RepoKitTheme {
32
+ pub name: String,
33
+ pub colors: RepoKitThemeColors,
34
+ }
@@ -1,22 +1,95 @@
1
- use crate::themes::theme::{RepoKitTheme, Theme, ThemeInputColors};
1
+ use std::collections::HashMap;
2
+
3
+ use crate::{
4
+ internal_filesystem::internal_filesystem::InternalFileSystem,
5
+ themes::{
6
+ built_in_themes::{money::MONEY, seeing_red::SEEING_RED, the_blues::THE_BLUES},
7
+ theme::Theme,
8
+ theme_colors::ThemeColors,
9
+ theme_inputs::{RepoKitTheme, ThemeInputColors},
10
+ },
11
+ };
2
12
 
3
13
  pub struct ThemeRegistry {
4
- pub theme: Theme,
14
+ pub theme: String,
15
+ pub default_theme: String,
16
+ pub themes: HashMap<String, Theme>,
5
17
  }
6
18
 
7
19
  impl ThemeRegistry {
8
20
  pub fn new() -> ThemeRegistry {
21
+ let (default_theme_name, built_in_themes) = ThemeRegistry::built_in_themes();
9
22
  ThemeRegistry {
10
- theme: ThemeRegistry::default_theme(),
23
+ themes: HashMap::from(built_in_themes),
24
+ theme: default_theme_name.to_string(),
25
+ default_theme: default_theme_name.to_string(),
26
+ }
27
+ }
28
+
29
+ pub fn set_theme(&mut self, root: &str, theme: &str) {
30
+ if self.themes.contains_key(theme) && self.theme != theme {
31
+ self.theme = theme.to_string();
32
+ InternalFileSystem::new(root).store_theme_preference(theme);
11
33
  }
12
34
  }
13
35
 
14
- pub fn register(&mut self, theme: &RepoKitTheme) {
15
- self.theme = Theme::from_configuration(theme);
36
+ pub fn current_theme(&self) -> &Theme {
37
+ if self.themes.contains_key(&self.theme) {
38
+ return self
39
+ .themes
40
+ .get(&self.theme)
41
+ .expect("the current theme was not found");
42
+ }
43
+ self.themes
44
+ .get(&self.default_theme)
45
+ .expect("default theme should always exist")
46
+ }
47
+
48
+ pub fn register_user_theme(&mut self, theme: &RepoKitTheme) {
49
+ self.themes
50
+ .insert(theme.name.clone(), Theme::from_configuration(theme));
51
+ }
52
+
53
+ pub fn register_theme(&mut self, theme: Theme) {
54
+ let name = theme.name.clone();
55
+ self.themes.insert(name, theme);
56
+ }
57
+
58
+ pub fn has(&self, theme: &str) -> bool {
59
+ self.themes.contains_key(theme)
60
+ }
61
+
62
+ fn built_in_themes() -> (String, [(String, Theme); 4]) {
63
+ let (default_theme_name, built_in_color_schemes) = ThemeRegistry::built_in_color_schemes();
64
+ (
65
+ default_theme_name,
66
+ built_in_color_schemes.map(|(name, colors)| {
67
+ (
68
+ name.to_string(),
69
+ Theme {
70
+ colors,
71
+ name: name.to_string(),
72
+ },
73
+ )
74
+ }),
75
+ )
76
+ }
77
+
78
+ fn built_in_color_schemes() -> (String, [(&'static str, ThemeColors); 4]) {
79
+ let default_theme_name = "default";
80
+ (
81
+ default_theme_name.to_string(),
82
+ [
83
+ (default_theme_name, ThemeRegistry::create_default()),
84
+ ("seeing-red", SEEING_RED),
85
+ ("the-blues", THE_BLUES),
86
+ ("money", MONEY),
87
+ ],
88
+ )
16
89
  }
17
90
 
18
- fn default_theme() -> Theme {
19
- Theme::new(ThemeInputColors {
91
+ fn create_default() -> ThemeColors {
92
+ ThemeColors::from_options(ThemeInputColors {
20
93
  prefixColor: None,
21
94
  commandColor: None,
22
95
  subcommandColor: None,
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repokit/core",
3
- "version": "2.1.0",
3
+ "version": "3.0.1",
4
4
  "description": "A knowledgebase for your repository - wrapped in a CLI",
5
5
  "keywords": [
6
6
  "cli",
@@ -53,6 +53,7 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@figliolia/child-process": "^1.0.4",
56
+ "@figliolia/semver": "^1.0.0",
56
57
  "@types/node": "^25.3.0",
57
58
  "@typescript-eslint/eslint-plugin": "^8.57.1",
58
59
  "@typescript-eslint/parser": "^8.57.1",
package/dist/Themes.d.mts DELETED
@@ -1,8 +0,0 @@
1
- import { RepoKitTheme } from "./RepoKitTheme.mjs";
2
-
3
- //#region externals/Themes.d.ts
4
- declare const SeeingRed: RepoKitTheme;
5
- declare const TheBlues: RepoKitTheme;
6
- declare const Green: RepoKitTheme;
7
- //#endregion
8
- export { Green, SeeingRed, TheBlues };
package/dist/Themes.mjs DELETED
@@ -1,31 +0,0 @@
1
- import { RepoKitTheme } from "./RepoKitTheme.mjs";
2
- //#region externals/Themes.ts
3
- const SeeingRed = new RepoKitTheme({
4
- prefixColor: "rgb(220, 36, 91)",
5
- commandColor: "rgb(220, 36, 36)",
6
- subcommandColor: "rgb(220, 131, 36)",
7
- argColor: "rgb(220, 205, 36)",
8
- descriptionColor: "rgb(179, 100, 151)",
9
- errorPrefixColor: "rgb(220, 36, 39)",
10
- highlightColor: "rgb(237, 175, 41)"
11
- });
12
- const TheBlues = new RepoKitTheme({
13
- prefixColor: "rgb(33, 111, 255)",
14
- commandColor: "rgb(52, 96, 255)",
15
- subcommandColor: "rgb(0, 157, 255)",
16
- argColor: "rgb(40, 175, 253)",
17
- descriptionColor: "rgb(100, 165, 179)",
18
- errorPrefixColor: "rgb(220, 36, 100)",
19
- highlightColor: "rgb(69, 219, 229)"
20
- });
21
- const Green = new RepoKitTheme({
22
- prefixColor: "rgb(26, 227, 133)",
23
- commandColor: "rgb(82, 234, 74)",
24
- subcommandColor: "rgb(51, 241, 162)",
25
- argColor: "rgb(124, 244, 102)",
26
- descriptionColor: "rgb(126, 168, 140)",
27
- errorPrefixColor: "rgb(220, 36, 100)",
28
- highlightColor: "rgb(25, 206, 91)"
29
- });
30
- //#endregion
31
- export { Green, SeeingRed, TheBlues };
@@ -1,31 +0,0 @@
1
- import { RepoKitTheme } from "./RepoKitTheme";
2
-
3
- export const SeeingRed = new RepoKitTheme({
4
- prefixColor: "rgb(220, 36, 91)",
5
- commandColor: "rgb(220, 36, 36)",
6
- subcommandColor: "rgb(220, 131, 36)",
7
- argColor: "rgb(220, 205, 36)",
8
- descriptionColor: "rgb(179, 100, 151)",
9
- errorPrefixColor: "rgb(220, 36, 39)",
10
- highlightColor: "rgb(237, 175, 41)",
11
- });
12
-
13
- export const TheBlues = new RepoKitTheme({
14
- prefixColor: "rgb(33, 111, 255)",
15
- commandColor: "rgb(52, 96, 255)",
16
- subcommandColor: "rgb(0, 157, 255)",
17
- argColor: "rgb(40, 175, 253)",
18
- descriptionColor: "rgb(100, 165, 179)",
19
- errorPrefixColor: "rgb(220, 36, 100)",
20
- highlightColor: "rgb(69, 219, 229)",
21
- });
22
-
23
- export const Green = new RepoKitTheme({
24
- prefixColor: "rgb(26, 227, 133)",
25
- commandColor: "rgb(82, 234, 74)",
26
- subcommandColor: "rgb(51, 241, 162)",
27
- argColor: "rgb(124, 244, 102)",
28
- descriptionColor: "rgb(126, 168, 140)",
29
- errorPrefixColor: "rgb(220, 36, 100)",
30
- highlightColor: "rgb(25, 206, 91)",
31
- });