11import { readFileSync , existsSync , statSync } from "fs" ;
22import { createInterface } from "readline" ;
33import type { ColorScheme } from "../types" ;
4- import { configureVim } from "./configs/vim" ;
5- import { configureVSCode } from "./configs/vscode" ;
6- import { configureCursor } from "./configs/cursor" ;
7- import { configureNeovim } from "./configs/neovim" ;
8- import { configureFoot } from "./configs/foot" ;
9- import { configureAlacritty } from "./configs/alacritty" ;
10- import { configureKitty } from "./configs/kitty" ;
11- import { configureWezTerm } from "./configs/wezterm" ;
12- import { configureXresources } from "./configs/xresources" ;
13- import { configureI3 } from "./configs/i3" ;
14- import { configureSway } from "./configs/sway" ;
15- import { configureRiver } from "./configs/river" ;
16- import { configureHyprland } from "./configs/hyprland" ;
17- import { configureMango } from "./configs/mango" ;
18- import { configureGtk3 } from "./configs/gtk3" ;
19- import { configureGtk4 } from "./configs/gtk4" ;
20- import { configureRofi } from "./configs/rofi" ;
21- import { configureDunst } from "./configs/dunst" ;
224
235type AppGroup = "Editors" | "Terminals" | "Window Managers" | "GTK" | "Other" ;
246type PathKind = "file" | "dir" ;
@@ -33,12 +15,12 @@ type AppConfig = {
3315 pathFlag : string ;
3416 pathKind : PathKind ;
3517 platforms : readonly Platform [ ] ;
36- configure : ( scheme : ColorScheme , overridePath ?: string ) => void ;
18+ configure : ( scheme : ColorScheme , overridePath ?: string ) => Promise < void > ;
3719} ;
3820
3921const LINUX = [ "linux" ] as const satisfies readonly Platform [ ] ;
4022const LINUX_MACOS = [ "linux" , "darwin" ] as const satisfies readonly Platform [ ] ;
41- const DESKTOP = [ "linux" , "darwin" , "win32" ] as const satisfies readonly Platform [ ] ;
23+ const ALL_PLATFORMS = [ "linux" , "darwin" , "win32" ] as const satisfies readonly Platform [ ] ;
4224
4325const APPS : AppConfig [ ] = [
4426 {
@@ -48,8 +30,9 @@ const APPS: AppConfig[] = [
4830 appFlag : "--vim" ,
4931 pathFlag : "--vim-path" ,
5032 pathKind : "file" ,
51- platforms : DESKTOP ,
52- configure : configureVim ,
33+ platforms : ALL_PLATFORMS ,
34+ configure : async ( scheme , overridePath ) =>
35+ ( await import ( "./configs/vim" ) ) . configureVim ( scheme , overridePath ) ,
5336 } ,
5437 {
5538 key : "vscode" ,
@@ -58,8 +41,9 @@ const APPS: AppConfig[] = [
5841 appFlag : "--vscode" ,
5942 pathFlag : "--vscode-path" ,
6043 pathKind : "dir" ,
61- platforms : DESKTOP ,
62- configure : configureVSCode ,
44+ platforms : ALL_PLATFORMS ,
45+ configure : async ( scheme , overridePath ) =>
46+ ( await import ( "./configs/vscode" ) ) . configureVSCode ( scheme , overridePath ) ,
6347 } ,
6448 {
6549 key : "cursor" ,
@@ -68,8 +52,9 @@ const APPS: AppConfig[] = [
6852 appFlag : "--cursor" ,
6953 pathFlag : "--cursor-path" ,
7054 pathKind : "dir" ,
71- platforms : DESKTOP ,
72- configure : configureCursor ,
55+ platforms : ALL_PLATFORMS ,
56+ configure : async ( scheme , overridePath ) =>
57+ ( await import ( "./configs/cursor" ) ) . configureCursor ( scheme , overridePath ) ,
7358 } ,
7459 {
7560 key : "neovim" ,
@@ -78,8 +63,9 @@ const APPS: AppConfig[] = [
7863 appFlag : "--neovim" ,
7964 pathFlag : "--neovim-path" ,
8065 pathKind : "file" ,
81- platforms : DESKTOP ,
82- configure : configureNeovim ,
66+ platforms : ALL_PLATFORMS ,
67+ configure : async ( scheme , overridePath ) =>
68+ ( await import ( "./configs/neovim" ) ) . configureNeovim ( scheme , overridePath ) ,
8369 } ,
8470 {
8571 key : "foot" ,
@@ -89,7 +75,8 @@ const APPS: AppConfig[] = [
8975 pathFlag : "--foot-path" ,
9076 pathKind : "file" ,
9177 platforms : LINUX ,
92- configure : configureFoot ,
78+ configure : async ( scheme , overridePath ) =>
79+ ( await import ( "./configs/foot" ) ) . configureFoot ( scheme , overridePath ) ,
9380 } ,
9481 {
9582 key : "alacritty" ,
@@ -98,8 +85,9 @@ const APPS: AppConfig[] = [
9885 appFlag : "--alacritty" ,
9986 pathFlag : "--alacritty-path" ,
10087 pathKind : "file" ,
101- platforms : DESKTOP ,
102- configure : configureAlacritty ,
88+ platforms : ALL_PLATFORMS ,
89+ configure : async ( scheme , overridePath ) =>
90+ ( await import ( "./configs/alacritty" ) ) . configureAlacritty ( scheme , overridePath ) ,
10391 } ,
10492 {
10593 key : "kitty" ,
@@ -109,7 +97,8 @@ const APPS: AppConfig[] = [
10997 pathFlag : "--kitty-path" ,
11098 pathKind : "file" ,
11199 platforms : LINUX_MACOS ,
112- configure : configureKitty ,
100+ configure : async ( scheme , overridePath ) =>
101+ ( await import ( "./configs/kitty" ) ) . configureKitty ( scheme , overridePath ) ,
113102 } ,
114103 {
115104 key : "wezterm" ,
@@ -118,8 +107,9 @@ const APPS: AppConfig[] = [
118107 appFlag : "--wezterm" ,
119108 pathFlag : "--wezterm-path" ,
120109 pathKind : "dir" ,
121- platforms : DESKTOP ,
122- configure : configureWezTerm ,
110+ platforms : ALL_PLATFORMS ,
111+ configure : async ( scheme , overridePath ) =>
112+ ( await import ( "./configs/wezterm" ) ) . configureWezTerm ( scheme , overridePath ) ,
123113 } ,
124114 {
125115 key : "xresources" ,
@@ -129,7 +119,8 @@ const APPS: AppConfig[] = [
129119 pathFlag : "--xresources-path" ,
130120 pathKind : "file" ,
131121 platforms : LINUX ,
132- configure : configureXresources ,
122+ configure : async ( scheme , overridePath ) =>
123+ ( await import ( "./configs/xresources" ) ) . configureXresources ( scheme , overridePath ) ,
133124 } ,
134125 {
135126 key : "i3" ,
@@ -139,7 +130,8 @@ const APPS: AppConfig[] = [
139130 pathFlag : "--i3-path" ,
140131 pathKind : "file" ,
141132 platforms : LINUX ,
142- configure : configureI3 ,
133+ configure : async ( scheme , overridePath ) =>
134+ ( await import ( "./configs/i3" ) ) . configureI3 ( scheme , overridePath ) ,
143135 } ,
144136 {
145137 key : "sway" ,
@@ -149,7 +141,8 @@ const APPS: AppConfig[] = [
149141 pathFlag : "--sway-path" ,
150142 pathKind : "file" ,
151143 platforms : LINUX ,
152- configure : configureSway ,
144+ configure : async ( scheme , overridePath ) =>
145+ ( await import ( "./configs/sway" ) ) . configureSway ( scheme , overridePath ) ,
153146 } ,
154147 {
155148 key : "river" ,
@@ -159,7 +152,8 @@ const APPS: AppConfig[] = [
159152 pathFlag : "--river-path" ,
160153 pathKind : "file" ,
161154 platforms : LINUX ,
162- configure : configureRiver ,
155+ configure : async ( scheme , overridePath ) =>
156+ ( await import ( "./configs/river" ) ) . configureRiver ( scheme , overridePath ) ,
163157 } ,
164158 {
165159 key : "hyprland" ,
@@ -169,7 +163,8 @@ const APPS: AppConfig[] = [
169163 pathFlag : "--hyprland-path" ,
170164 pathKind : "file" ,
171165 platforms : LINUX ,
172- configure : configureHyprland ,
166+ configure : async ( scheme , overridePath ) =>
167+ ( await import ( "./configs/hyprland" ) ) . configureHyprland ( scheme , overridePath ) ,
173168 } ,
174169 {
175170 key : "mango" ,
@@ -179,7 +174,8 @@ const APPS: AppConfig[] = [
179174 pathFlag : "--mango-path" ,
180175 pathKind : "file" ,
181176 platforms : LINUX ,
182- configure : configureMango ,
177+ configure : async ( scheme , overridePath ) =>
178+ ( await import ( "./configs/mango" ) ) . configureMango ( scheme , overridePath ) ,
183179 } ,
184180 {
185181 key : "gtk3" ,
@@ -189,7 +185,8 @@ const APPS: AppConfig[] = [
189185 pathFlag : "--gtk3-path" ,
190186 pathKind : "file" ,
191187 platforms : LINUX ,
192- configure : configureGtk3 ,
188+ configure : async ( scheme , overridePath ) =>
189+ ( await import ( "./configs/gtk3" ) ) . configureGtk3 ( scheme , overridePath ) ,
193190 } ,
194191 {
195192 key : "gtk4" ,
@@ -199,7 +196,8 @@ const APPS: AppConfig[] = [
199196 pathFlag : "--gtk4-path" ,
200197 pathKind : "file" ,
201198 platforms : LINUX ,
202- configure : configureGtk4 ,
199+ configure : async ( scheme , overridePath ) =>
200+ ( await import ( "./configs/gtk4" ) ) . configureGtk4 ( scheme , overridePath ) ,
203201 } ,
204202 {
205203 key : "rofi" ,
@@ -209,7 +207,8 @@ const APPS: AppConfig[] = [
209207 pathFlag : "--rofi-path" ,
210208 pathKind : "file" ,
211209 platforms : LINUX ,
212- configure : configureRofi ,
210+ configure : async ( scheme , overridePath ) =>
211+ ( await import ( "./configs/rofi" ) ) . configureRofi ( scheme , overridePath ) ,
213212 } ,
214213 {
215214 key : "dunst" ,
@@ -219,7 +218,8 @@ const APPS: AppConfig[] = [
219218 pathFlag : "--dunst-path" ,
220219 pathKind : "file" ,
221220 platforms : LINUX ,
222- configure : configureDunst ,
221+ configure : async ( scheme , overridePath ) =>
222+ ( await import ( "./configs/dunst" ) ) . configureDunst ( scheme , overridePath ) ,
223223 } ,
224224] ;
225225
@@ -370,7 +370,7 @@ async function main() {
370370
371371 const hasExplicitFlags = args . some ( ( arg ) => appFlags . includes ( arg ) ) ;
372372 const configAll = args . includes ( "--all" ) || ! hasExplicitFlags ;
373- const configs : Array < [ boolean , ( ) => void , string ] > = APPS . map ( ( app ) => [
373+ const configs : Array < [ boolean , ( ) => Promise < void > , string ] > = APPS . map ( ( app ) => [
374374 ( configAll && app . platforms . includes ( process . platform ) ) || args . includes ( app . appFlag ) ,
375375 ( ) => app . configure ( scheme , pathOverrides [ app . key ] ) ,
376376 app . name ,
@@ -396,12 +396,12 @@ async function main() {
396396 }
397397
398398 console . log ( "Configuring colorscheme...\n" ) ;
399- configs . forEach ( ( [ shouldRun , configure , name ] ) => {
399+ for ( const [ shouldRun , configure , name ] of configs ) {
400400 if ( shouldRun ) {
401- configure ( ) ;
401+ await configure ( ) ;
402402 console . log ( `✓ Configured ${ name } ` ) ;
403403 }
404- } ) ;
404+ }
405405}
406406
407407try {
0 commit comments