@repokit/core 2.0.7 → 3.0.0

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 (46) hide show
  1. package/Cargo.lock +113 -7
  2. package/Cargo.toml +3 -2
  3. package/README.md +45 -0
  4. package/dist/RepoKitConfig.d.mts +4 -1
  5. package/dist/RepoKitConfig.mjs +3 -1
  6. package/dist/RepoKitTheme.d.mts +47 -0
  7. package/dist/RepoKitTheme.mjs +45 -0
  8. package/dist/index.d.mts +4 -3
  9. package/dist/index.mjs +2 -1
  10. package/dist/types.d.mts +18 -5
  11. package/externals/RepoKitConfig.ts +10 -2
  12. package/externals/RepoKitTheme.ts +44 -0
  13. package/externals/index.ts +1 -0
  14. package/externals/types.ts +25 -4
  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/configuration/configuration.rs +2 -2
  19. package/internals/internal_commands/help.rs +57 -45
  20. package/internals/internal_commands/internal_registry.rs +5 -4
  21. package/internals/internal_commands/list_commands.rs +3 -3
  22. package/internals/internal_commands/list_owners.rs +10 -10
  23. package/internals/internal_commands/list_themes.rs +113 -0
  24. package/internals/internal_commands/locate_command.rs +8 -2
  25. package/internals/internal_commands/mod.rs +1 -0
  26. package/internals/internal_commands/onboarder.rs +10 -4
  27. package/internals/internal_commands/register_command.rs +3 -3
  28. package/internals/internal_commands/search_commands.rs +3 -3
  29. package/internals/internal_commands/upgrade_repokit.rs +5 -1
  30. package/internals/internal_filesystem/internal_filesystem.rs +124 -3
  31. package/internals/logger/logger.rs +44 -56
  32. package/internals/main.rs +2 -0
  33. package/internals/repokit/interfaces.rs +3 -0
  34. package/internals/repokit/repokit.rs +9 -6
  35. package/internals/themes/built_in_themes/mod.rs +3 -0
  36. package/internals/themes/built_in_themes/money.rs +41 -0
  37. package/internals/themes/built_in_themes/seeing_red.rs +41 -0
  38. package/internals/themes/built_in_themes/the_blues.rs +41 -0
  39. package/internals/themes/mod.rs +5 -0
  40. package/internals/themes/theme.rs +108 -0
  41. package/internals/themes/theme_colors.rs +36 -0
  42. package/internals/themes/theme_inputs.rs +34 -0
  43. package/internals/themes/theme_registry.rs +102 -0
  44. package/internals/validations/command_validations.rs +8 -8
  45. package/media/seeing-red.webp +0 -0
  46. package/package.json +5 -4
@@ -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
+ }
@@ -0,0 +1,102 @@
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
+ };
12
+
13
+ pub struct ThemeRegistry {
14
+ pub theme: String,
15
+ pub default_theme: String,
16
+ pub themes: HashMap<String, Theme>,
17
+ }
18
+
19
+ impl ThemeRegistry {
20
+ pub fn new() -> ThemeRegistry {
21
+ let (default_theme_name, built_in_themes) = ThemeRegistry::built_in_themes();
22
+ ThemeRegistry {
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);
33
+ }
34
+ }
35
+
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
+ )
89
+ }
90
+
91
+ fn create_default() -> ThemeColors {
92
+ ThemeColors::from_options(ThemeInputColors {
93
+ prefixColor: None,
94
+ commandColor: None,
95
+ subcommandColor: None,
96
+ argColor: None,
97
+ descriptionColor: None,
98
+ errorPrefixColor: None,
99
+ highlightColor: None,
100
+ })
101
+ }
102
+ }
@@ -61,7 +61,7 @@ impl CommandValidations {
61
61
  Logger::info(
62
62
  format!(
63
63
  "I encountered a command named {} that conflicts with one of my internals",
64
- Logger::blue_bright(name),
64
+ Logger::with_theme(|theme| theme.highlight(name)),
65
65
  )
66
66
  .as_str(),
67
67
  );
@@ -81,8 +81,8 @@ impl CommandValidations {
81
81
  Logger::info(
82
82
  format!(
83
83
  "I encountered a command named {} in your {} file that conflicts with one of my internals",
84
- Logger::blue_bright(name),
85
- Logger::blue_bright("repokit.ts"),
84
+ Logger::with_theme(|theme|theme.highlight(name)),
85
+ Logger::with_theme(|theme|theme.highlight("repokit.ts")),
86
86
  )
87
87
  .as_str(),
88
88
  );
@@ -117,8 +117,8 @@ impl CommandValidations {
117
117
  fn on_external_root_collision(&self, command: &RepoKitCommand) {
118
118
  Logger::info(format!(
119
119
  "I encountered a package command named {} that conflicts with a command in your {} file",
120
- Logger::blue_bright(&command.name),
121
- Logger::blue_bright("repokit.ts")
120
+ Logger::with_theme(|theme|theme.highlight(&command.name)),
121
+ Logger::with_theme(|theme|theme.highlight("repokit.ts"))
122
122
  )
123
123
  .as_str(),
124
124
  );
@@ -131,7 +131,7 @@ impl CommandValidations {
131
131
  Logger::info(
132
132
  format!(
133
133
  "I encountered two packages with the name {}",
134
- Logger::blue_bright(&command.name),
134
+ Logger::with_theme(|theme| theme.highlight(&command.name)),
135
135
  )
136
136
  .as_str(),
137
137
  );
@@ -139,12 +139,12 @@ impl CommandValidations {
139
139
  println!(
140
140
  "{}1. {}",
141
141
  Logger::indent(None),
142
- Logger::blue_bright(collision_path)
142
+ Logger::with_theme(|theme| theme.highlight(collision_path))
143
143
  );
144
144
  println!(
145
145
  "{}2. {}\n",
146
146
  Logger::indent(None),
147
- Logger::blue_bright(&command.location)
147
+ Logger::with_theme(|theme| theme.highlight(&command.location))
148
148
  );
149
149
  Logger::exit_with_info("Please rename one of these");
150
150
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repokit/core",
3
- "version": "2.0.7",
3
+ "version": "3.0.0",
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",
@@ -62,11 +63,11 @@
62
63
  "eslint-plugin-import": "^2.32.0",
63
64
  "eslint-plugin-simple-import-sort": "^12.1.1",
64
65
  "eslint-plugin-unused-imports": "^4.4.1",
65
- "oxfmt": "^0.41.0",
66
+ "oxfmt": "^0.42.0",
66
67
  "oxlint": "^1.42.0",
67
- "oxlint-tsgolint": "^0.17.0",
68
+ "oxlint-tsgolint": "^0.18.1",
68
69
  "tsdown": "^0.21.0",
69
70
  "tsx": "^4.21.0",
70
- "typescript": "^5.9.3"
71
+ "typescript": "^6.0.2"
71
72
  }
72
73
  }