anubis-ui 1.2.15 → 1.2.16
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/README.md +315 -249
- package/index.d.ts +10 -10
- package/index.html +20 -0
- package/package.json +10 -6
- package/src/config/colors.config.json +242 -9
- package/src/config/force.config.json +1 -0
- package/src/config/utilities.config.json +141 -0
- package/src/interfaces/color.interface.ts +9 -0
- package/src/interfaces/config.interface.ts +11 -15
- package/src/interfaces/preset.interface.ts +28 -11
- package/src/tools/config.tool.ts +27 -35
- package/src/tools/extraction/extractClasses.ts +164 -36
- package/src/tools/fileStuff/config.file.ts +44 -0
- package/src/tools/fileStuff/css.file.ts +47 -0
- package/src/tools/fileStuff/file.tools.ts +9 -12
- package/src/tools/logger.ts +4 -11
- package/src/tools/mapping/mapClassIntoRule.ts +329 -190
- package/src/tools/mapping/mapColorIntoDeclaration.ts +14 -0
- package/src/tools/output/css.output.ts +105 -0
- package/src/tools/validation/color.validation.ts +68 -0
- package/tests/README.md +54 -0
- package/tests/validation/color.validation.test.ts +182 -0
- package/tsconfig.json +11 -2
- package/vitest.config.ts +19 -0
- package/src/config/presets.config.json +0 -51
- package/src/config/qol.config.json +0 -78
- package/src/interfaces/declaration.interface.ts +0 -10
- package/src/tools/fileStuff/configFile.ts +0 -26
- package/src/tools/fileStuff/cssFile.ts +0 -37
package/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
declare module 'anubis-ui' {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { Plugin } from 'vite';
|
|
3
|
+
import type { IEnvConfig } from './dist/interfaces/config.interface';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const plugin: Plugin;
|
|
6
|
+
const config: IEnvConfig;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const anubis: {
|
|
9
|
+
plugin: typeof plugin;
|
|
10
|
+
config: typeof config;
|
|
11
|
+
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
}
|
|
13
|
+
export default anubis;
|
|
14
|
+
}
|
package/index.html
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>AnubisUI Test</title>
|
|
7
|
+
<link rel="stylesheet" href="src/css/_anubis.scss" />
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
.paragraph-small {
|
|
11
|
+
font-weight: var(--weight-bold);
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
14
|
+
</head>
|
|
15
|
+
<body class="body--light">
|
|
16
|
+
<div class="rounded bg-neutral border-primary-highest-thick shadow-neutral-wide">
|
|
17
|
+
<btn color="primary" textColor="secondary">Test button with variants</button>
|
|
18
|
+
</div>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anubis-ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.16",
|
|
4
4
|
"description": "Class-based css generator",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -16,9 +16,12 @@
|
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
18
|
"dev": "rm -rf dist; npm run prepare; node src/manual/build.js",
|
|
19
|
-
"build": "tsc",
|
|
19
|
+
"build": "tsc && tsc-alias",
|
|
20
20
|
"preinstall": "npm run build",
|
|
21
|
-
"prepare": "npm run build"
|
|
21
|
+
"prepare": "npm run build",
|
|
22
|
+
"test": "vitest",
|
|
23
|
+
"test:run": "vitest run",
|
|
24
|
+
"test:ui": "vitest --ui"
|
|
22
25
|
},
|
|
23
26
|
"style": "dist/_anubis.scss",
|
|
24
27
|
"repository": {
|
|
@@ -33,11 +36,12 @@
|
|
|
33
36
|
"homepage": "https://github.com/HugoLMTY/anubis-ui#readme",
|
|
34
37
|
"devDependencies": {
|
|
35
38
|
"@types/node": "^22.14.1",
|
|
39
|
+
"tsc-alias": "^1.8.16",
|
|
36
40
|
"typescript": "^5.8.3",
|
|
37
|
-
"vite": "^6.3.2"
|
|
41
|
+
"vite": "^6.3.2",
|
|
42
|
+
"vitest": "^3.2.4"
|
|
38
43
|
},
|
|
39
44
|
"dependencies": {
|
|
40
|
-
"fast-glob": "^3.3.3"
|
|
41
|
-
"fs": "^0.0.1-security"
|
|
45
|
+
"fast-glob": "^3.3.3"
|
|
42
46
|
}
|
|
43
47
|
}
|
|
@@ -1,9 +1,242 @@
|
|
|
1
|
-
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
{
|
|
2
|
+
"none": {
|
|
3
|
+
"light": "transparent",
|
|
4
|
+
"dark": "transparent"
|
|
5
|
+
},
|
|
6
|
+
"text": {
|
|
7
|
+
"light": "#000",
|
|
8
|
+
"dark": "#fff"
|
|
9
|
+
},
|
|
10
|
+
"text-invert": {
|
|
11
|
+
"light": "#fff",
|
|
12
|
+
"dark": "#000"
|
|
13
|
+
},
|
|
14
|
+
"text-link": {
|
|
15
|
+
"light": "#0a5a8a",
|
|
16
|
+
"dark": "#0f84cb"
|
|
17
|
+
},
|
|
18
|
+
"accent": {
|
|
19
|
+
"light": "#0f84cb",
|
|
20
|
+
"dark": "#1a94db"
|
|
21
|
+
},
|
|
22
|
+
"accent-lowest": {
|
|
23
|
+
"light": "#f0f8ff",
|
|
24
|
+
"dark": "#082a3f"
|
|
25
|
+
},
|
|
26
|
+
"accent-lower": {
|
|
27
|
+
"light": "#e1f2ff",
|
|
28
|
+
"dark": "#0a5a8a"
|
|
29
|
+
},
|
|
30
|
+
"accent-low": {
|
|
31
|
+
"light": "#b3d9ff",
|
|
32
|
+
"dark": "#0e6b9a"
|
|
33
|
+
},
|
|
34
|
+
"accent-medium": {
|
|
35
|
+
"light": "#0f84cb",
|
|
36
|
+
"dark": "#1a94db"
|
|
37
|
+
},
|
|
38
|
+
"accent-high": {
|
|
39
|
+
"light": "#0c6ba3",
|
|
40
|
+
"dark": "#b3d9ff"
|
|
41
|
+
},
|
|
42
|
+
"accent-higher": {
|
|
43
|
+
"light": "#094a7a",
|
|
44
|
+
"dark": "#e1f2ff"
|
|
45
|
+
},
|
|
46
|
+
"accent-highest": {
|
|
47
|
+
"light": "#082a3f",
|
|
48
|
+
"dark": "#f0f8ff"
|
|
49
|
+
},
|
|
50
|
+
"primary": {
|
|
51
|
+
"light": "#0f84cb",
|
|
52
|
+
"dark": "#1a94db"
|
|
53
|
+
},
|
|
54
|
+
"primary-lowest": {
|
|
55
|
+
"light": "#f0f8ff",
|
|
56
|
+
"dark": "#082a3f"
|
|
57
|
+
},
|
|
58
|
+
"primary-lower": {
|
|
59
|
+
"light": "#e1f2ff",
|
|
60
|
+
"dark": "#0a5a8a"
|
|
61
|
+
},
|
|
62
|
+
"primary-low": {
|
|
63
|
+
"light": "#b3d9ff",
|
|
64
|
+
"dark": "#0e6b9a"
|
|
65
|
+
},
|
|
66
|
+
"primary-medium": {
|
|
67
|
+
"light": "#0f84cb",
|
|
68
|
+
"dark": "#1a94db"
|
|
69
|
+
},
|
|
70
|
+
"primary-high": {
|
|
71
|
+
"light": "#0c6ba3",
|
|
72
|
+
"dark": "#b3d9ff"
|
|
73
|
+
},
|
|
74
|
+
"primary-higher": {
|
|
75
|
+
"light": "#094a7a",
|
|
76
|
+
"dark": "#e1f2ff"
|
|
77
|
+
},
|
|
78
|
+
"primary-highest": {
|
|
79
|
+
"light": "#082a3f",
|
|
80
|
+
"dark": "#f0f8ff"
|
|
81
|
+
},
|
|
82
|
+
"secondary": {
|
|
83
|
+
"light": "#3b5161",
|
|
84
|
+
"dark": "#4a5f6f"
|
|
85
|
+
},
|
|
86
|
+
"secondary-lowest": {
|
|
87
|
+
"light": "#f5f7f8",
|
|
88
|
+
"dark": "#1e2a30"
|
|
89
|
+
},
|
|
90
|
+
"secondary-lower": {
|
|
91
|
+
"light": "#e8ecf0",
|
|
92
|
+
"dark": "#2a3a42"
|
|
93
|
+
},
|
|
94
|
+
"secondary-low": {
|
|
95
|
+
"light": "#b3c2cc",
|
|
96
|
+
"dark": "#354a55"
|
|
97
|
+
},
|
|
98
|
+
"secondary-medium": {
|
|
99
|
+
"light": "#3b5161",
|
|
100
|
+
"dark": "#4a5f6f"
|
|
101
|
+
},
|
|
102
|
+
"secondary-high": {
|
|
103
|
+
"light": "#2f404e",
|
|
104
|
+
"dark": "#b3c2cc"
|
|
105
|
+
},
|
|
106
|
+
"secondary-higher": {
|
|
107
|
+
"light": "#232f3a",
|
|
108
|
+
"dark": "#e8ecf0"
|
|
109
|
+
},
|
|
110
|
+
"secondary-highest": {
|
|
111
|
+
"light": "#1e2a30",
|
|
112
|
+
"dark": "#f5f7f8"
|
|
113
|
+
},
|
|
114
|
+
"neutral": {
|
|
115
|
+
"light": "#64748b",
|
|
116
|
+
"dark": "#64748b"
|
|
117
|
+
},
|
|
118
|
+
"neutral-lowest": {
|
|
119
|
+
"light": "#ffffff",
|
|
120
|
+
"dark": "#0f172a"
|
|
121
|
+
},
|
|
122
|
+
"neutral-lower": {
|
|
123
|
+
"light": "#f1f5f9",
|
|
124
|
+
"dark": "#475569"
|
|
125
|
+
},
|
|
126
|
+
"neutral-low": {
|
|
127
|
+
"light": "#cbd5e1",
|
|
128
|
+
"dark": "#475569"
|
|
129
|
+
},
|
|
130
|
+
"neutral-medium": {
|
|
131
|
+
"light": "#64748b",
|
|
132
|
+
"dark": "#64748b"
|
|
133
|
+
},
|
|
134
|
+
"neutral-high": {
|
|
135
|
+
"light": "#475569",
|
|
136
|
+
"dark": "#cbd5e1"
|
|
137
|
+
},
|
|
138
|
+
"neutral-higher": {
|
|
139
|
+
"light": "#1e293b",
|
|
140
|
+
"dark": "#f1f5f9"
|
|
141
|
+
},
|
|
142
|
+
"neutral-highest": {
|
|
143
|
+
"light": "#141e57",
|
|
144
|
+
"dark": "#ffffff"
|
|
145
|
+
},
|
|
146
|
+
"success": {
|
|
147
|
+
"light": "#00c99e",
|
|
148
|
+
"dark": "#25e2b3"
|
|
149
|
+
},
|
|
150
|
+
"success-lowest": {
|
|
151
|
+
"light": "#eafff7",
|
|
152
|
+
"dark": "#00302a"
|
|
153
|
+
},
|
|
154
|
+
"success-lower": {
|
|
155
|
+
"light": "#cdfeeb",
|
|
156
|
+
"dark": "#006756"
|
|
157
|
+
},
|
|
158
|
+
"success-low": {
|
|
159
|
+
"light": "#63f2ca",
|
|
160
|
+
"dark": "#00a481"
|
|
161
|
+
},
|
|
162
|
+
"success-medium": {
|
|
163
|
+
"light": "#00c99e",
|
|
164
|
+
"dark": "#25e2b3"
|
|
165
|
+
},
|
|
166
|
+
"success-high": {
|
|
167
|
+
"light": "#00836b",
|
|
168
|
+
"dark": "#63f2ca"
|
|
169
|
+
},
|
|
170
|
+
"success-higher": {
|
|
171
|
+
"light": "#005548",
|
|
172
|
+
"dark": "#cdfeeb"
|
|
173
|
+
},
|
|
174
|
+
"success-highest": {
|
|
175
|
+
"light": "#00302a",
|
|
176
|
+
"dark": "#eafff7"
|
|
177
|
+
},
|
|
178
|
+
"danger": {
|
|
179
|
+
"light": "#e64d4b",
|
|
180
|
+
"dark": "#f17a78"
|
|
181
|
+
},
|
|
182
|
+
"danger-lowest": {
|
|
183
|
+
"light": "#fdf3f3",
|
|
184
|
+
"dark": "#420e0d"
|
|
185
|
+
},
|
|
186
|
+
"danger-lower": {
|
|
187
|
+
"light": "#fde3e3",
|
|
188
|
+
"dark": "#932221"
|
|
189
|
+
},
|
|
190
|
+
"danger-low": {
|
|
191
|
+
"light": "#f8aaa9",
|
|
192
|
+
"dark": "#d3312f"
|
|
193
|
+
},
|
|
194
|
+
"danger-medium": {
|
|
195
|
+
"light": "#e64d4b",
|
|
196
|
+
"dark": "#f17a78"
|
|
197
|
+
},
|
|
198
|
+
"danger-high": {
|
|
199
|
+
"light": "#b12624",
|
|
200
|
+
"dark": "#f8aaa9"
|
|
201
|
+
},
|
|
202
|
+
"danger-higher": {
|
|
203
|
+
"light": "#7a2322",
|
|
204
|
+
"dark": "#fde3e3"
|
|
205
|
+
},
|
|
206
|
+
"danger-highest": {
|
|
207
|
+
"light": "#420e0d",
|
|
208
|
+
"dark": "#fdf3f3"
|
|
209
|
+
},
|
|
210
|
+
"warning": {
|
|
211
|
+
"light": "#ff9a00",
|
|
212
|
+
"dark": "#ffbd1b"
|
|
213
|
+
},
|
|
214
|
+
"warning-lowest": {
|
|
215
|
+
"light": "#fffbea",
|
|
216
|
+
"dark": "#481700"
|
|
217
|
+
},
|
|
218
|
+
"warning-lower": {
|
|
219
|
+
"light": "#fff3c5",
|
|
220
|
+
"dark": "#983c08"
|
|
221
|
+
},
|
|
222
|
+
"warning-low": {
|
|
223
|
+
"light": "#ffd346",
|
|
224
|
+
"dark": "#e27300"
|
|
225
|
+
},
|
|
226
|
+
"warning-medium": {
|
|
227
|
+
"light": "#ff9a00",
|
|
228
|
+
"dark": "#ffbd1b"
|
|
229
|
+
},
|
|
230
|
+
"warning-high": {
|
|
231
|
+
"light": "#bb4e02",
|
|
232
|
+
"dark": "#ffd346"
|
|
233
|
+
},
|
|
234
|
+
"warning-higher": {
|
|
235
|
+
"light": "#7c310b",
|
|
236
|
+
"dark": "#fff3c5"
|
|
237
|
+
},
|
|
238
|
+
"warning-highest": {
|
|
239
|
+
"light": "#481700",
|
|
240
|
+
"dark": "#fffbea"
|
|
241
|
+
}
|
|
242
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"prefix": "bg",
|
|
4
|
+
"declaration": "background: ${color}"
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
"prefix": "text",
|
|
8
|
+
"declaration": "color: ${color}"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"prefix": "border",
|
|
12
|
+
"declaration": "border-width: ${value} !important; border-color: ${color} !important; border-style: solid;",
|
|
13
|
+
"variations": {
|
|
14
|
+
"default": "4px",
|
|
15
|
+
"thinest": "1px",
|
|
16
|
+
"thiner": "2px",
|
|
17
|
+
"thin": "3px",
|
|
18
|
+
"thick": "6px",
|
|
19
|
+
"thicker": "8px",
|
|
20
|
+
"thickest": "10px",
|
|
21
|
+
"node": "0.2rem"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"prefix": "inner-border",
|
|
26
|
+
"declaration": "box-shadow: inset 0px 0px 0px ${value} ${color}",
|
|
27
|
+
"variations": {
|
|
28
|
+
"default": "4px",
|
|
29
|
+
"thinest": "1px",
|
|
30
|
+
"thiner": "2px",
|
|
31
|
+
"thin2": "3px",
|
|
32
|
+
"thick": "6px",
|
|
33
|
+
"thicker": "8px",
|
|
34
|
+
"thickest": "10px",
|
|
35
|
+
"node": "0.2rem"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"prefix": "shadow",
|
|
40
|
+
"declaration": "box-shadow: ${value} ${color}",
|
|
41
|
+
"variations": {
|
|
42
|
+
"default": "0px 0px 7px 1px",
|
|
43
|
+
"densest": "0px 0px 3px 1px",
|
|
44
|
+
"lower": "0px 0px 5px 1px",
|
|
45
|
+
"dense": "0px 0px 5px 1px",
|
|
46
|
+
"wide": "0px 0px 10px 1px",
|
|
47
|
+
"wider": "0px 0px 15px 1px",
|
|
48
|
+
"widest": "0px 0px 20px 1px"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"prefix": "blur",
|
|
53
|
+
"declaration": "backdrop-filter: blur(${value})",
|
|
54
|
+
"variations": {
|
|
55
|
+
"default": "3px"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"prefix": "smooth",
|
|
60
|
+
"declaration": "transition-duration: ${value}",
|
|
61
|
+
"variations": {
|
|
62
|
+
"default": "0.1s",
|
|
63
|
+
"slowest": "0.5s",
|
|
64
|
+
"slower": "0.3s",
|
|
65
|
+
"slow": "0.2s",
|
|
66
|
+
"quick": "0.07s",
|
|
67
|
+
"quicker": "0.05s",
|
|
68
|
+
"quickest": "0.03s"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"prefix": "rounded",
|
|
73
|
+
"declaration": "border-radius: ${value}",
|
|
74
|
+
"variations": {
|
|
75
|
+
"default": "8px",
|
|
76
|
+
"square": "0px",
|
|
77
|
+
"xs": "2px",
|
|
78
|
+
"sm": "4px",
|
|
79
|
+
"md": "8px",
|
|
80
|
+
"lg": "12px",
|
|
81
|
+
"xl": "16px",
|
|
82
|
+
"very": "9999px",
|
|
83
|
+
"full": "50%",
|
|
84
|
+
"half": "100%"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"prefix": "border",
|
|
89
|
+
"declaration": "border-style: ${value}",
|
|
90
|
+
"variations": {
|
|
91
|
+
"solid": "solid",
|
|
92
|
+
"dashed": "dashed",
|
|
93
|
+
"dotted": "dotted"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"prefix": "position",
|
|
98
|
+
"declaration": "position: ${value}",
|
|
99
|
+
"variations": {
|
|
100
|
+
"relative": "relative",
|
|
101
|
+
"absolute": "absolute"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"prefix": "size",
|
|
106
|
+
"declaration": "font-size: ${value} !important",
|
|
107
|
+
"export-variations": true,
|
|
108
|
+
"variations": {
|
|
109
|
+
"2xs": "10px",
|
|
110
|
+
"xs": "12px",
|
|
111
|
+
"sm": "14px",
|
|
112
|
+
"md": "16px",
|
|
113
|
+
"lg": "18px",
|
|
114
|
+
"xl": "20px",
|
|
115
|
+
"2xl": "24px",
|
|
116
|
+
"3xl": "30px",
|
|
117
|
+
"4xl": "36px",
|
|
118
|
+
"5xl": "48px",
|
|
119
|
+
"6xl": "60px",
|
|
120
|
+
"7xl": "72px",
|
|
121
|
+
"8xl": "96px",
|
|
122
|
+
"9xl": "128px"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"prefix": "weight",
|
|
127
|
+
"declaration": "font-weight: ${value} !important",
|
|
128
|
+
"export-variations": true,
|
|
129
|
+
"variations": {
|
|
130
|
+
"thin": "100",
|
|
131
|
+
"extra-light": "200",
|
|
132
|
+
"light": "300",
|
|
133
|
+
"normal": "400",
|
|
134
|
+
"medium": "500",
|
|
135
|
+
"semi-bold": "600",
|
|
136
|
+
"bold": "700",
|
|
137
|
+
"extra-bold": "800",
|
|
138
|
+
"black": "900"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
]
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
targets: string|string[],
|
|
5
|
-
ignore: string[]
|
|
6
|
-
}
|
|
1
|
+
import { IColor } from './color.interface';
|
|
2
|
+
import { IPreset } from './preset.interface';
|
|
3
|
+
import { IFileConfig } from './files.interface';
|
|
7
4
|
|
|
8
5
|
export interface IEnvConfig {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
files: IFilePatterns,
|
|
6
|
+
utilities: IPreset[];
|
|
7
|
+
files: IFileConfig;
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
/** User-given classes to force the css rule creation */
|
|
10
|
+
force: string[];
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
12
|
+
colors: IColor;
|
|
13
|
+
states: string[];
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
export interface IVariation {
|
|
2
|
-
|
|
2
|
+
[key: string]: string;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export interface IPreset {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
// [key: string]: string
|
|
7
|
+
prefix: string;
|
|
8
|
+
declaration: string;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/** When true, class can be called without variation, creating a rule with default variation */
|
|
11
|
+
standalone?: boolean;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Controls how variations are exported as SCSS variables:
|
|
15
|
+
* - true: export only variations that are used in the codebase
|
|
16
|
+
* - "always": export all variations regardless of usage
|
|
17
|
+
* - undefined/false: do not export variations
|
|
18
|
+
*/
|
|
19
|
+
'export-variations'?: boolean | 'always';
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
21
|
+
/** List of every possible variations */
|
|
22
|
+
variations: IVariation;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface IRuleInfo {
|
|
26
|
+
selector: string;
|
|
27
|
+
declaration: string;
|
|
28
|
+
color?: string;
|
|
29
|
+
variant?: {
|
|
30
|
+
prefix: string;
|
|
31
|
+
variantName: string;
|
|
32
|
+
variantValue: string;
|
|
33
|
+
shouldExport: boolean;
|
|
34
|
+
};
|
|
35
|
+
}
|
package/src/tools/config.tool.ts
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
import { IEnvConfig } from
|
|
2
|
-
import { readUserConfigFile, userConfig } from
|
|
3
|
-
import { log } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { IEnvConfig } from '@interfaces/config.interface';
|
|
2
|
+
import { readUserConfigFile, checkUserConfigFile, userConfig } from '@tools/fileStuff/config.file';
|
|
3
|
+
import { log } from '@tools/logger';
|
|
4
|
+
import { validateColors } from '@validation/color.validation';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
7
|
|
|
8
8
|
const anubisConfigFolder = path.join(__dirname, '..', '..', 'src', 'config');
|
|
9
9
|
const anubisConfigFiles = [
|
|
10
|
-
'
|
|
10
|
+
'utilities',
|
|
11
11
|
'files',
|
|
12
12
|
'colors',
|
|
13
13
|
'states',
|
|
14
|
-
'
|
|
14
|
+
'force',
|
|
15
15
|
]
|
|
16
16
|
|
|
17
17
|
const config = {
|
|
18
|
-
|
|
19
|
-
presets: [],
|
|
18
|
+
utilities: [],
|
|
20
19
|
|
|
21
20
|
force: [],
|
|
22
21
|
|
|
23
22
|
files: { targets: [], ignore: [] },
|
|
24
|
-
colors:
|
|
23
|
+
colors: {},
|
|
25
24
|
states: [],
|
|
26
25
|
} as IEnvConfig
|
|
27
26
|
|
|
28
27
|
const init = () => {
|
|
29
28
|
readUserConfigFile()
|
|
30
|
-
|
|
31
|
-
checkUserConfig()
|
|
29
|
+
checkUserConfigFile(anubisConfigFiles)
|
|
32
30
|
|
|
33
31
|
for (const file of anubisConfigFiles) {
|
|
34
32
|
let configToUse = null
|
|
@@ -38,40 +36,34 @@ const init = () => {
|
|
|
38
36
|
configToUse = userConfig[file]
|
|
39
37
|
} else {
|
|
40
38
|
const filePath = path.join(anubisConfigFolder, `${file}.config.json`)
|
|
39
|
+
const fileExists = fs.existsSync(filePath)
|
|
40
|
+
if (!fileExists) { return }
|
|
41
|
+
|
|
41
42
|
const configContent = fs.readFileSync(filePath, { encoding: 'utf-8' })
|
|
42
43
|
if (!configContent) { continue }
|
|
43
44
|
|
|
44
45
|
configToUse = JSON.parse(configContent)
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
switch (file) {
|
|
49
|
+
case 'colors':
|
|
50
|
+
validateColors(config[file])
|
|
51
|
+
break
|
|
52
|
+
|
|
53
|
+
case 'force':
|
|
54
|
+
const forceClasses = userConfig?.['force']
|
|
55
|
+
if (forceClasses?.length) {
|
|
56
|
+
log(`Forcing the creation of ${forceClasses?.length} classes`)
|
|
57
|
+
}
|
|
58
|
+
break
|
|
59
|
+
}
|
|
51
60
|
|
|
52
|
-
|
|
53
|
-
log(`Forcing the creation of ${forceClasses?.length} classes`)
|
|
54
|
-
config.force = userConfig['force']
|
|
61
|
+
config[file as keyof typeof config] = configToUse
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
return config
|
|
58
65
|
}
|
|
59
66
|
|
|
60
|
-
const checkUserConfig = () => {
|
|
61
|
-
if (!userConfig) { return }
|
|
62
|
-
|
|
63
|
-
// todo - also check values
|
|
64
|
-
const userConfigKeys = Object.keys(userConfig)
|
|
65
|
-
|
|
66
|
-
const unknownKeys = userConfigKeys?.filter(key => !anubisConfigFiles.includes(key) && key !== 'force')
|
|
67
|
-
if (!unknownKeys?.length) { return }
|
|
68
|
-
|
|
69
|
-
log(`${unknownKeys?.length} unknown config keys found in user config file`)
|
|
70
|
-
for (const key of unknownKeys) {
|
|
71
|
-
log(`- ${key}`)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
67
|
export {
|
|
76
68
|
init,
|
|
77
69
|
config
|