@repokit/core 3.0.0 → 3.0.2

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/Cargo.lock CHANGED
@@ -239,7 +239,7 @@ checksum = "a96887878f22d7bad8a3b6dc5b7440e0ada9a245242924394987b21cf2210a4c"
239
239
 
240
240
  [[package]]
241
241
  name = "repokit"
242
- version = "3.0.0"
242
+ version = "3.0.2"
243
243
  dependencies = [
244
244
  "alphanumeric-sort",
245
245
  "colored",
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "repokit"
3
- version = "3.0.0"
3
+ version = "3.0.2"
4
4
  edition = "2024"
5
5
 
6
6
  [[bin]]
package/README.md CHANGED
@@ -232,47 +232,54 @@ If your command needs to reason about the file system, keep this in mind.
232
232
 
233
233
  The Repokit CLI can be customized to support themes that better match your team's visual preferences.
234
234
 
235
- Repokit comes with 4 pre-built themes that you can use in your `RepoKitConfig`.
235
+ Repokit comes with 4 pre-built themes that you view by running
236
236
 
237
- ```typescript
238
- import {
239
- RepoKitConfig,
240
- SeeingRed, // A red theme
241
- TheBlues, // A blue theme
242
- Green, // A green theme
243
- } from "@repokit/core";
244
-
245
- export const Kit = new RepoKitConfig({
246
- project: "My Project",
247
- theme: SeeingRed, // Specify a theme here
248
- });
237
+ ```bash
238
+ repokit themes
249
239
  ```
250
240
 
251
- By omitting the `theme` property `RepoKit` will use its default visuals.
241
+ To Set your desired theme, you can run
252
242
 
253
- In addition to built-in themes, you can create your own using the `RepoKitTheme`
243
+ ```bash
244
+ repokit themes --set <theme-name>
245
+ ```
246
+
247
+ RepoKit also allows you to design your own themes using the `themes` property on your `RepoKitConfig`:
254
248
 
255
249
  ```typescript
256
250
  import { RepoKitConfig, RepoKitTheme } from "@repokit/core";
257
251
 
258
252
  export const Kit = new RepoKitConfig({
259
253
  project: "My Project",
260
- theme: new RepoKitTheme({
261
- prefixColor: "rgb(220, 36, 91)",
262
- commandColor: "rgb(220, 36, 36)",
263
- subcommandColor: "rgb(220, 131, 36)",
264
- argColor: "rgb(220, 205, 36)",
265
- descriptionColor: "rgb(179, 100, 151)",
266
- errorPrefixColor: "rgb(220, 36, 39)",
267
- highlightColor: "rgb(237, 175, 41)",
268
- }),
254
+ themes: [
255
+ new RepoKitTheme({
256
+ name: "my-awesome-theme",
257
+ colors: {
258
+ prefixColor: "rgb(220, 36, 91)",
259
+ commandColor: "rgb(220, 36, 36)",
260
+ subcommandColor: "rgb(220, 131, 36)",
261
+ argColor: "rgb(220, 205, 36)",
262
+ descriptionColor: "rgb(179, 100, 151)",
263
+ errorPrefixColor: "rgb(220, 36, 39)",
264
+ highlightColor: "rgb(237, 175, 41)",
265
+ },
266
+ }),
267
+ ],
269
268
  });
270
269
  ```
271
270
 
272
- All properties on the `RepoKitTheme` are optional overrides for `RepoKit`'s default styling. A color can be any CSS-valid `rgb()` string.
271
+ All properties on the `RepoKitTheme.colors` are optional overrides for `RepoKit`'s default styling. A color can be any CSS-valid `rgb()` string.
273
272
 
274
273
  <img src="media/seeing-red.webp" width="100%" alt="seeing red theme" />
275
274
 
275
+ Once a theme is added to your `RepoKitConfig`, it becomes available by running
276
+
277
+ ```bash
278
+ repokit themes
279
+ ```
280
+
281
+ <img src="media/list-themes.webp" width="100%" alt="listing-themes" />
282
+
276
283
  ## Motivation
277
284
 
278
285
  I worked in a codebase at Google that used just about every programming language in existence. Each team had their own methodology for exposing commands, scripts, and API's for their team's day-to-day development needs.
@@ -1,4 +1,4 @@
1
- CURRENT_VERSION="3.0.0"
1
+ CURRENT_VERSION="3.0.2"
2
2
  CWD=$(pwd)
3
3
 
4
4
  REPLACEMENT="/node_modules"
@@ -5,7 +5,6 @@ use std::sync::MutexGuard;
5
5
 
6
6
  use colored::{ColoredString, Colorize};
7
7
 
8
- use crate::repokit::interfaces::RepoKitConfig;
9
8
  use crate::themes::theme::Theme;
10
9
  use crate::themes::theme_registry::ThemeRegistry;
11
10
 
@@ -17,11 +16,8 @@ static THEMES: LazyLock<Mutex<ThemeRegistry>> = LazyLock::new(|| Mutex::new(Them
17
16
  pub struct Logger {}
18
17
 
19
18
  impl Logger {
20
- pub fn configure(configuration: &RepoKitConfig) {
21
- Logger::set_name(&configuration.project);
22
- for theme in &configuration.themes {
23
- Logger::with_registry(|mut registry| registry.register_user_theme(theme))
24
- }
19
+ pub fn set_name(value: &str) {
20
+ *REGISTERED_NAME.lock().unwrap() = value.to_string();
25
21
  }
26
22
 
27
23
  pub fn info(message: &str) {
@@ -42,6 +38,16 @@ impl Logger {
42
38
  exit(0);
43
39
  }
44
40
 
41
+ pub fn list(items: &[&str], indentation: Option<i32>) {
42
+ Logger::with_surrounding_space(|| {
43
+ let mut pointer = 0;
44
+ for item in items {
45
+ println!("{}{}. {}", Logger::indent(indentation), pointer + 1, item);
46
+ pointer += 1
47
+ }
48
+ })
49
+ }
50
+
45
51
  pub fn space_around(message: &str) {
46
52
  println!("\n{}{}\n", Logger::info_prefix(), message);
47
53
  }
@@ -115,8 +121,4 @@ impl Logger {
115
121
  format!("{}: ", theme.error_prefix(&REGISTERED_NAME.lock().unwrap()))
116
122
  })
117
123
  }
118
-
119
- fn set_name(value: &str) {
120
- *REGISTERED_NAME.lock().unwrap() = value.to_string();
121
- }
122
124
  }
@@ -23,7 +23,10 @@ pub struct RepoKit {
23
23
 
24
24
  impl RepoKit {
25
25
  pub fn new(root: String, configuration: RepoKitConfig) -> RepoKit {
26
- Logger::configure(&configuration);
26
+ Logger::set_name(&configuration.project);
27
+ for theme in &configuration.themes {
28
+ Logger::with_registry(|mut registry| registry.register_user_theme(theme))
29
+ }
27
30
  let theme = InternalFileSystem::new(&root).read_theme_preference();
28
31
  Logger::with_registry(|mut registry| registry.set_theme(&root, &theme));
29
32
  RepoKit {
@@ -46,6 +46,9 @@ impl ThemeRegistry {
46
46
  }
47
47
 
48
48
  pub fn register_user_theme(&mut self, theme: &RepoKitTheme) {
49
+ if self.themes.contains_key(&theme.name) {
50
+ self.on_naming_conflict(&theme.name);
51
+ }
49
52
  self.themes
50
53
  .insert(theme.name.clone(), Theme::from_configuration(theme));
51
54
  }
@@ -99,4 +102,24 @@ impl ThemeRegistry {
99
102
  highlightColor: None,
100
103
  })
101
104
  }
105
+
106
+ fn on_naming_conflict(&self, name: &str) {
107
+ if ThemeRegistry::built_in_color_schemes()
108
+ .1
109
+ .map(|t| t.0)
110
+ .contains(&name)
111
+ {
112
+ println!(
113
+ "{}: I've discovered a theme that conflicts with one of my iternals. Please rename your {} theme",
114
+ self.current_theme().error_prefix("RepoKit"),
115
+ self.current_theme().highlight(name)
116
+ )
117
+ } else {
118
+ println!(
119
+ "{}: I've discovered two themes with the name {}. Please rename one of them",
120
+ self.current_theme().error_prefix("RepoKit"),
121
+ self.current_theme().highlight(name)
122
+ )
123
+ }
124
+ }
102
125
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repokit/core",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "A knowledgebase for your repository - wrapped in a CLI",
5
5
  "keywords": [
6
6
  "cli",