@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 +1 -1
- package/Cargo.toml +1 -1
- package/README.md +32 -25
- package/installation/install.sh +1 -1
- package/internals/logger/logger.rs +12 -10
- package/internals/repokit/repokit.rs +4 -1
- package/internals/themes/theme_registry.rs +23 -0
- package/media/list-themes.webp +0 -0
- package/package.json +1 -1
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
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
|
|
235
|
+
Repokit comes with 4 pre-built themes that you view by running
|
|
236
236
|
|
|
237
|
-
```
|
|
238
|
-
|
|
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
|
-
|
|
241
|
+
To Set your desired theme, you can run
|
|
252
242
|
|
|
253
|
-
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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.
|
package/installation/install.sh
CHANGED
|
@@ -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
|
|
21
|
-
|
|
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(®ISTERED_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::
|
|
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
|