@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
package/Cargo.lock CHANGED
@@ -27,6 +27,12 @@ dependencies = [
27
27
  "serde",
28
28
  ]
29
29
 
30
+ [[package]]
31
+ name = "cfg-if"
32
+ version = "1.0.4"
33
+ source = "registry+https://github.com/rust-lang/crates.io-index"
34
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
35
+
30
36
  [[package]]
31
37
  name = "colored"
32
38
  version = "3.1.1"
@@ -61,6 +67,38 @@ version = "0.8.21"
61
67
  source = "registry+https://github.com/rust-lang/crates.io-index"
62
68
  checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
63
69
 
70
+ [[package]]
71
+ name = "dirs"
72
+ version = "6.0.0"
73
+ source = "registry+https://github.com/rust-lang/crates.io-index"
74
+ checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
75
+ dependencies = [
76
+ "dirs-sys",
77
+ ]
78
+
79
+ [[package]]
80
+ name = "dirs-sys"
81
+ version = "0.5.0"
82
+ source = "registry+https://github.com/rust-lang/crates.io-index"
83
+ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
84
+ dependencies = [
85
+ "libc",
86
+ "option-ext",
87
+ "redox_users",
88
+ "windows-sys",
89
+ ]
90
+
91
+ [[package]]
92
+ name = "getrandom"
93
+ version = "0.2.17"
94
+ source = "registry+https://github.com/rust-lang/crates.io-index"
95
+ checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
96
+ dependencies = [
97
+ "cfg-if",
98
+ "libc",
99
+ "wasi",
100
+ ]
101
+
64
102
  [[package]]
65
103
  name = "globset"
66
104
  version = "0.4.18"
@@ -96,6 +134,21 @@ version = "1.0.17"
96
134
  source = "registry+https://github.com/rust-lang/crates.io-index"
97
135
  checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
98
136
 
137
+ [[package]]
138
+ name = "libc"
139
+ version = "0.2.183"
140
+ source = "registry+https://github.com/rust-lang/crates.io-index"
141
+ checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
142
+
143
+ [[package]]
144
+ name = "libredox"
145
+ version = "0.1.15"
146
+ source = "registry+https://github.com/rust-lang/crates.io-index"
147
+ checksum = "7ddbf48fd451246b1f8c2610bd3b4ac0cc6e149d89832867093ab69a17194f08"
148
+ dependencies = [
149
+ "libc",
150
+ ]
151
+
99
152
  [[package]]
100
153
  name = "log"
101
154
  version = "0.4.29"
@@ -114,6 +167,12 @@ version = "0.2.1"
114
167
  source = "registry+https://github.com/rust-lang/crates.io-index"
115
168
  checksum = "f5438dd2b2ff4c6df6e1ce22d825ed2fa93ee2922235cc45186991717f0a892d"
116
169
 
170
+ [[package]]
171
+ name = "option-ext"
172
+ version = "0.2.0"
173
+ source = "registry+https://github.com/rust-lang/crates.io-index"
174
+ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
175
+
117
176
  [[package]]
118
177
  name = "pin-project-lite"
119
178
  version = "0.2.16"
@@ -131,13 +190,24 @@ dependencies = [
131
190
 
132
191
  [[package]]
133
192
  name = "quote"
134
- version = "1.0.44"
193
+ version = "1.0.45"
135
194
  source = "registry+https://github.com/rust-lang/crates.io-index"
136
- checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
195
+ checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
137
196
  dependencies = [
138
197
  "proc-macro2",
139
198
  ]
140
199
 
200
+ [[package]]
201
+ name = "redox_users"
202
+ version = "0.5.2"
203
+ source = "registry+https://github.com/rust-lang/crates.io-index"
204
+ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac"
205
+ dependencies = [
206
+ "getrandom",
207
+ "libredox",
208
+ "thiserror",
209
+ ]
210
+
141
211
  [[package]]
142
212
  name = "regex"
143
213
  version = "1.12.3"
@@ -169,7 +239,7 @@ checksum = "a96887878f22d7bad8a3b6dc5b7440e0ada9a245242924394987b21cf2210a4c"
169
239
 
170
240
  [[package]]
171
241
  name = "repokit"
172
- version = "2.1.0"
242
+ version = "3.0.1"
173
243
  dependencies = [
174
244
  "alphanumeric-sort",
175
245
  "colored",
@@ -178,6 +248,7 @@ dependencies = [
178
248
  "regex",
179
249
  "serde",
180
250
  "serde_json",
251
+ "shellexpand",
181
252
  "tokio",
182
253
  ]
183
254
 
@@ -233,17 +304,46 @@ dependencies = [
233
304
  "zmij",
234
305
  ]
235
306
 
307
+ [[package]]
308
+ name = "shellexpand"
309
+ version = "3.1.2"
310
+ source = "registry+https://github.com/rust-lang/crates.io-index"
311
+ checksum = "32824fab5e16e6c4d86dc1ba84489390419a39f97699852b66480bb87d297ed8"
312
+ dependencies = [
313
+ "dirs",
314
+ ]
315
+
236
316
  [[package]]
237
317
  name = "syn"
238
- version = "2.0.114"
318
+ version = "2.0.117"
239
319
  source = "registry+https://github.com/rust-lang/crates.io-index"
240
- checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a"
320
+ checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
241
321
  dependencies = [
242
322
  "proc-macro2",
243
323
  "quote",
244
324
  "unicode-ident",
245
325
  ]
246
326
 
327
+ [[package]]
328
+ name = "thiserror"
329
+ version = "2.0.18"
330
+ source = "registry+https://github.com/rust-lang/crates.io-index"
331
+ checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
332
+ dependencies = [
333
+ "thiserror-impl",
334
+ ]
335
+
336
+ [[package]]
337
+ name = "thiserror-impl"
338
+ version = "2.0.18"
339
+ source = "registry+https://github.com/rust-lang/crates.io-index"
340
+ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
341
+ dependencies = [
342
+ "proc-macro2",
343
+ "quote",
344
+ "syn",
345
+ ]
346
+
247
347
  [[package]]
248
348
  name = "tokio"
249
349
  version = "1.50.0"
@@ -269,6 +369,12 @@ dependencies = [
269
369
  "winapi-util",
270
370
  ]
271
371
 
372
+ [[package]]
373
+ name = "wasi"
374
+ version = "0.11.1+wasi-snapshot-preview1"
375
+ source = "registry+https://github.com/rust-lang/crates.io-index"
376
+ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
377
+
272
378
  [[package]]
273
379
  name = "winapi-util"
274
380
  version = "0.1.11"
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "repokit"
3
- version = "2.1.0"
3
+ version = "3.0.1"
4
4
  edition = "2024"
5
5
 
6
6
  [[bin]]
@@ -16,3 +16,4 @@ alphanumeric-sort = "1.5.5"
16
16
  tokio = "1.50.0"
17
17
  ignore = "0.4.25"
18
18
  regex = { version = "1.12.3", features = ["std", "unicode"] }
19
+ shellexpand = "3.1.2"
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.
@@ -5,12 +5,12 @@ import { RepoKitCommand } from "./RepoKitCommand.mjs";
5
5
  //#region externals/RepoKitConfig.d.ts
6
6
  declare class RepoKitConfig {
7
7
  project: string;
8
- theme?: RepoKitTheme;
8
+ themes: RepoKitTheme[];
9
9
  thirdParty: RepoKitCommand[];
10
10
  commands: Record<string, ICommand>;
11
11
  constructor({
12
- theme,
13
12
  project,
13
+ themes,
14
14
  commands,
15
15
  thirdParty
16
16
  }: IRepoKitConfig);
@@ -2,11 +2,11 @@ import { RepoKitCommand } from "./RepoKitCommand.mjs";
2
2
  //#region externals/RepoKitConfig.ts
3
3
  var RepoKitConfig = class {
4
4
  project;
5
- theme;
5
+ themes;
6
6
  thirdParty;
7
7
  commands;
8
- constructor({ theme, project, commands = {}, thirdParty = [] }) {
9
- this.theme = theme;
8
+ constructor({ project, themes = [], commands = {}, thirdParty = [] }) {
9
+ this.themes = themes;
10
10
  this.project = project;
11
11
  this.commands = commands;
12
12
  this.thirdParty = thirdParty.map((command) => new RepoKitCommand(command));
@@ -1,4 +1,4 @@
1
- import { RGBString } from "./types.mjs";
1
+ import { IRepoKitTheme, RepoKitThemeColors } from "./types.mjs";
2
2
 
3
3
  //#region externals/RepoKitTheme.d.ts
4
4
  /**
@@ -13,35 +13,35 @@ import { RGBString } from "./types.mjs";
13
13
  *
14
14
  * export const RepoKit = new RepoKitConfig({
15
15
  * project: "Repokit",
16
- * theme: new RepoKitTheme({
17
- * prefixColor: "rgb(220, 36, 91)",
18
- * commandColor: "rgb(220, 36, 36)",
19
- * subcommandColor: "rgb(220, 131, 36)",
20
- * argColor: "rgb(220, 205, 36)",
21
- * descriptionColor: "rgb(95, 28, 71)",
22
- * errorPrefixColor: "rgb(220, 36, 39)",
23
- * hightlightColor: "rgb(8, 98, 255)",
24
- * }),
16
+ * themes: [
17
+ * new RepoKitTheme({
18
+ * name: "my-theme",
19
+ * colors: {
20
+ * prefixColor: "rgb(220, 36, 91)",
21
+ * commandColor: "rgb(220, 36, 36)",
22
+ * subcommandColor: "rgb(220, 131, 36)",
23
+ * argColor: "rgb(220, 205, 36)",
24
+ * descriptionColor: "rgb(95, 28, 71)",
25
+ * errorPrefixColor: "rgb(220, 36, 39)",
26
+ * hightlightColor: "rgb(8, 98, 255)",
27
+ * }
28
+ * }),
29
+ * ]
25
30
  * });
26
31
  * ```
32
+ *
33
+ * To enable your theme you can run
34
+ * ```bash
35
+ * repokit themes --set my-theme
36
+ * ```
27
37
  */
28
- declare class RepoKitTheme {
29
- prefixColor?: RGBString;
30
- commandColor?: RGBString;
31
- subcommandColor?: RGBString;
32
- argColor?: RGBString;
33
- descriptionColor?: RGBString;
34
- errorPrefixColor?: RGBString;
35
- highlightColor?: RGBString;
38
+ declare class RepoKitTheme implements IRepoKitTheme {
39
+ readonly name: string;
40
+ readonly colors: RepoKitThemeColors;
36
41
  constructor({
37
- prefixColor,
38
- commandColor,
39
- subcommandColor,
40
- argColor,
41
- descriptionColor,
42
- errorPrefixColor,
43
- highlightColor
44
- }: RepoKitTheme);
42
+ name,
43
+ colors
44
+ }: IRepoKitTheme);
45
45
  }
46
46
  //#endregion
47
47
  export { RepoKitTheme };
@@ -11,34 +11,34 @@
11
11
  *
12
12
  * export const RepoKit = new RepoKitConfig({
13
13
  * project: "Repokit",
14
- * theme: new RepoKitTheme({
15
- * prefixColor: "rgb(220, 36, 91)",
16
- * commandColor: "rgb(220, 36, 36)",
17
- * subcommandColor: "rgb(220, 131, 36)",
18
- * argColor: "rgb(220, 205, 36)",
19
- * descriptionColor: "rgb(95, 28, 71)",
20
- * errorPrefixColor: "rgb(220, 36, 39)",
21
- * hightlightColor: "rgb(8, 98, 255)",
22
- * }),
14
+ * themes: [
15
+ * new RepoKitTheme({
16
+ * name: "my-theme",
17
+ * colors: {
18
+ * prefixColor: "rgb(220, 36, 91)",
19
+ * commandColor: "rgb(220, 36, 36)",
20
+ * subcommandColor: "rgb(220, 131, 36)",
21
+ * argColor: "rgb(220, 205, 36)",
22
+ * descriptionColor: "rgb(95, 28, 71)",
23
+ * errorPrefixColor: "rgb(220, 36, 39)",
24
+ * hightlightColor: "rgb(8, 98, 255)",
25
+ * }
26
+ * }),
27
+ * ]
23
28
  * });
24
29
  * ```
30
+ *
31
+ * To enable your theme you can run
32
+ * ```bash
33
+ * repokit themes --set my-theme
34
+ * ```
25
35
  */
26
36
  var RepoKitTheme = class {
27
- prefixColor;
28
- commandColor;
29
- subcommandColor;
30
- argColor;
31
- descriptionColor;
32
- errorPrefixColor;
33
- highlightColor;
34
- constructor({ prefixColor, commandColor, subcommandColor, argColor, descriptionColor, errorPrefixColor, highlightColor }) {
35
- this.prefixColor = prefixColor;
36
- this.commandColor = commandColor;
37
- this.subcommandColor = subcommandColor;
38
- this.argColor = argColor;
39
- this.descriptionColor = descriptionColor;
40
- this.errorPrefixColor = errorPrefixColor;
41
- this.highlightColor = highlightColor;
37
+ name;
38
+ colors;
39
+ constructor({ name, colors }) {
40
+ this.name = name;
41
+ this.colors = colors;
42
42
  }
43
43
  };
44
44
  //#endregion
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { RepoKitTheme } from "./RepoKitTheme.mjs";
2
- import { AsyncTask, ICommand, ILocatedCommand, IRepoKitCommand, IRepoKitConfig, RGBString } from "./types.mjs";
3
- import { RepoKitCommand } from "./RepoKitCommand.mjs";
4
2
  import { RepoKitConfig } from "./RepoKitConfig.mjs";
5
- import { Green, SeeingRed, TheBlues } from "./Themes.mjs";
6
- export { AsyncTask, Green, ICommand, ILocatedCommand, IRepoKitCommand, IRepoKitConfig, RGBString, RepoKitCommand, RepoKitConfig, RepoKitTheme, SeeingRed, TheBlues };
3
+ import { AsyncTask, ICommand, ILocatedCommand, IRepoKitCommand, IRepoKitConfig, IRepoKitTheme, RGBString, RepoKitThemeColors } from "./types.mjs";
4
+ import { RepoKitCommand } from "./RepoKitCommand.mjs";
5
+ export { AsyncTask, ICommand, ILocatedCommand, IRepoKitCommand, IRepoKitConfig, IRepoKitTheme, RGBString, RepoKitCommand, RepoKitConfig, RepoKitTheme, RepoKitThemeColors };
package/dist/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import { RepoKitCommand } from "./RepoKitCommand.mjs";
2
2
  import { RepoKitConfig } from "./RepoKitConfig.mjs";
3
3
  import { RepoKitTheme } from "./RepoKitTheme.mjs";
4
- import { Green, SeeingRed, TheBlues } from "./Themes.mjs";
5
- export { Green, RepoKitCommand, RepoKitConfig, RepoKitTheme, SeeingRed, TheBlues };
4
+ export { RepoKitCommand, RepoKitConfig, RepoKitTheme };
package/dist/types.d.mts CHANGED
@@ -1,12 +1,8 @@
1
- import { RepoKitTheme } from "./RepoKitTheme.mjs";
2
- import { RepoKitCommand } from "./RepoKitCommand.mjs";
1
+ import { RepoKitConfig } from "./RepoKitConfig.mjs";
3
2
 
4
3
  //#region externals/types.d.ts
5
- interface IRepoKitConfig {
4
+ interface IRepoKitConfig extends Omit<Partial<RepoKitConfig>, "project"> {
6
5
  project: string;
7
- thirdParty?: RepoKitCommand[];
8
- commands?: Record<string, ICommand>;
9
- theme?: RepoKitTheme;
10
6
  }
11
7
  interface IRepoKitCommand {
12
8
  name: string;
@@ -25,5 +21,18 @@ interface ILocatedCommand extends IRepoKitCommand {
25
21
  type AsyncTask<T> = () => Promise<T>;
26
22
  type OptionalSpace = " " | "";
27
23
  type RGBString = `rgb(${number},${OptionalSpace}${number},${OptionalSpace}${number})`;
24
+ interface RepoKitThemeColors {
25
+ prefixColor?: RGBString;
26
+ commandColor?: RGBString;
27
+ subcommandColor?: RGBString;
28
+ argColor?: RGBString;
29
+ descriptionColor?: RGBString;
30
+ errorPrefixColor?: RGBString;
31
+ highlightColor?: RGBString;
32
+ }
33
+ interface IRepoKitTheme {
34
+ name: string;
35
+ colors: RepoKitThemeColors;
36
+ }
28
37
  //#endregion
29
- export { AsyncTask, ICommand, ILocatedCommand, IRepoKitCommand, IRepoKitConfig, RGBString };
38
+ export { AsyncTask, ICommand, ILocatedCommand, IRepoKitCommand, IRepoKitConfig, IRepoKitTheme, RGBString, RepoKitThemeColors };
@@ -5,16 +5,16 @@ import type { ICommand, IRepoKitConfig } from "./types";
5
5
 
6
6
  export class RepoKitConfig {
7
7
  project: string;
8
- theme?: RepoKitTheme;
8
+ themes: RepoKitTheme[];
9
9
  thirdParty: RepoKitCommand[];
10
10
  commands: Record<string, ICommand>;
11
11
  constructor({
12
- theme,
13
12
  project,
13
+ themes = [],
14
14
  commands = {},
15
15
  thirdParty = [],
16
16
  }: IRepoKitConfig) {
17
- this.theme = theme;
17
+ this.themes = themes;
18
18
  this.project = project;
19
19
  this.commands = commands;
20
20
  this.thirdParty = thirdParty.map(command => new RepoKitCommand(command));
@@ -1,4 +1,4 @@
1
- import type { RGBString } from "./types";
1
+ import type { IRepoKitTheme, RepoKitThemeColors } from "./types";
2
2
 
3
3
  /**
4
4
  * Repokit Theme
@@ -12,41 +12,33 @@ import type { RGBString } from "./types";
12
12
  *
13
13
  * export const RepoKit = new RepoKitConfig({
14
14
  * project: "Repokit",
15
- * theme: new RepoKitTheme({
16
- * prefixColor: "rgb(220, 36, 91)",
17
- * commandColor: "rgb(220, 36, 36)",
18
- * subcommandColor: "rgb(220, 131, 36)",
19
- * argColor: "rgb(220, 205, 36)",
20
- * descriptionColor: "rgb(95, 28, 71)",
21
- * errorPrefixColor: "rgb(220, 36, 39)",
22
- * hightlightColor: "rgb(8, 98, 255)",
23
- * }),
15
+ * themes: [
16
+ * new RepoKitTheme({
17
+ * name: "my-theme",
18
+ * colors: {
19
+ * prefixColor: "rgb(220, 36, 91)",
20
+ * commandColor: "rgb(220, 36, 36)",
21
+ * subcommandColor: "rgb(220, 131, 36)",
22
+ * argColor: "rgb(220, 205, 36)",
23
+ * descriptionColor: "rgb(95, 28, 71)",
24
+ * errorPrefixColor: "rgb(220, 36, 39)",
25
+ * hightlightColor: "rgb(8, 98, 255)",
26
+ * }
27
+ * }),
28
+ * ]
24
29
  * });
25
30
  * ```
31
+ *
32
+ * To enable your theme you can run
33
+ * ```bash
34
+ * repokit themes --set my-theme
35
+ * ```
26
36
  */
27
- export class RepoKitTheme {
28
- prefixColor?: RGBString;
29
- commandColor?: RGBString;
30
- subcommandColor?: RGBString;
31
- argColor?: RGBString;
32
- descriptionColor?: RGBString;
33
- errorPrefixColor?: RGBString;
34
- highlightColor?: RGBString;
35
- constructor({
36
- prefixColor,
37
- commandColor,
38
- subcommandColor,
39
- argColor,
40
- descriptionColor,
41
- errorPrefixColor,
42
- highlightColor,
43
- }: RepoKitTheme) {
44
- this.prefixColor = prefixColor;
45
- this.commandColor = commandColor;
46
- this.subcommandColor = subcommandColor;
47
- this.argColor = argColor;
48
- this.descriptionColor = descriptionColor;
49
- this.errorPrefixColor = errorPrefixColor;
50
- this.highlightColor = highlightColor;
37
+ export class RepoKitTheme implements IRepoKitTheme {
38
+ public readonly name: string;
39
+ public readonly colors: RepoKitThemeColors;
40
+ constructor({ name, colors }: IRepoKitTheme) {
41
+ this.name = name;
42
+ this.colors = colors;
51
43
  }
52
44
  }
@@ -1,5 +1,4 @@
1
1
  export * from "./RepoKitCommand";
2
2
  export * from "./RepoKitConfig";
3
3
  export * from "./RepoKitTheme";
4
- export * from "./Themes";
5
4
  export * from "./types";
@@ -1,11 +1,10 @@
1
- import type { RepoKitCommand } from "./RepoKitCommand";
2
- import type { RepoKitTheme } from "./RepoKitTheme";
1
+ import type { RepoKitConfig } from "./RepoKitConfig";
3
2
 
4
- export interface IRepoKitConfig {
3
+ export interface IRepoKitConfig extends Omit<
4
+ Partial<RepoKitConfig>,
5
+ "project"
6
+ > {
5
7
  project: string;
6
- thirdParty?: RepoKitCommand[];
7
- commands?: Record<string, ICommand>;
8
- theme?: RepoKitTheme;
9
8
  }
10
9
 
11
10
  export interface IRepoKitCommand {
@@ -31,3 +30,18 @@ type OptionalSpace = " " | "";
31
30
 
32
31
  export type RGBString =
33
32
  `rgb(${number},${OptionalSpace}${number},${OptionalSpace}${number})`;
33
+
34
+ export interface RepoKitThemeColors {
35
+ prefixColor?: RGBString;
36
+ commandColor?: RGBString;
37
+ subcommandColor?: RGBString;
38
+ argColor?: RGBString;
39
+ descriptionColor?: RGBString;
40
+ errorPrefixColor?: RGBString;
41
+ highlightColor?: RGBString;
42
+ }
43
+
44
+ export interface IRepoKitTheme {
45
+ name: string;
46
+ colors: RepoKitThemeColors;
47
+ }
@@ -1,4 +1,4 @@
1
- CURRENT_VERSION="2.1.0"
1
+ CURRENT_VERSION="3.0.1"
2
2
  CWD=$(pwd)
3
3
 
4
4
  REPLACEMENT="/node_modules"
@@ -36,8 +36,14 @@ if [ -f .repokit ]; then
36
36
  fi
37
37
  fi
38
38
 
39
- touch ".repokit"
40
- printf "$CURRENT_VERSION" > ".repokit"
39
+ DOT_FILE=".repokit"
40
+ TEMP_FILE=".repokit_tmp";
41
+
42
+ touch "$DOT_FILE"
43
+
44
+ printf "$CURRENT_VERSION\n" > "$TEMP_FILE"
45
+ tail +2 "$DOT_FILE" >> "$TEMP_FILE"
46
+ mv "$TEMP_FILE" "$DOT_FILE"
41
47
 
42
48
 
43
49
  cd $CWD