anubis-ui 1.0.13 → 1.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Improba
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -20,6 +20,7 @@ AnubisUI (Autonomous Nominative Utility Based Intuitive Styler) is a Vite plugin
20
20
  5. [Prefix/Declaration relations](#prefixdeclaration-relations)
21
21
  6. [Architecture](#architecture)
22
22
  7. [Credits](#credits)
23
+ 8. [Licence](#licence)
23
24
 
24
25
  ## Features
25
26
  - 🎨 Dynamic CSS generation based on utility classes
@@ -128,7 +129,45 @@ $background-opacity: (
128
129
  ## Configuration
129
130
  AnubisUI uses several configuration files located in the `src/config` directory:
130
131
  <br />
131
- Customisation from root file `anubis.config.json` will appear in future updates
132
+ To override default configuration, add a `anubis.config.json` in project root folder.
133
+ >Overriding completly replaces default configuration. You need to copy/paste it and add yours if you want to keep the default too.
134
+ <br />
135
+
136
+ For every config you want to change, add the corresponding section in your config file:
137
+
138
+ ```js
139
+ {
140
+ // files.config.json
141
+ "files": {
142
+ "targets": ["/.vue"],
143
+ "ignore": []
144
+ },
145
+
146
+ // colors.config.json
147
+ "colors": ["primary", "secondary"],
148
+
149
+ // selectors.config.json
150
+ "selectors": {
151
+ "states": ["hover"],
152
+ "prefixes": ["bg", "text"]
153
+ },
154
+
155
+ // presets.config.json
156
+ "presets": {
157
+ "border": [
158
+ { "default": "4px" }
159
+ ]
160
+ }
161
+ }
162
+ ```
163
+ <sup>anubis.config.json (example)</sup>
164
+
165
+ Only the sections you want to override need to be included - other sections will use default values. Not every
166
+ > Presets is still unstable, use at your own risks
167
+ <br />
168
+ You __MUST__ use the exact same [presets](#presets-presetsconfigjson) names syntax to keep it working, but variations key/values can change.
169
+ <br />
170
+ Copy-paste is recommanded
132
171
 
133
172
  ---
134
173
  ### Colors (`colors.config.json`)
@@ -146,7 +185,6 @@ Define your color palette
146
185
  "warning",
147
186
  "danger"
148
187
  ]
149
- // no need to includes (lowest, lower, low, high, higher, highest) variants as long as the color name is present in the class
150
188
  ```
151
189
  </details>
152
190
 
@@ -168,6 +206,8 @@ Specify which files to scan for classes
168
206
  ---
169
207
  ### Presets (`presets.config.json`)
170
208
  Configure common style presets
209
+ > If overrided in config, default key/value are __REQUIRED__
210
+
171
211
  <details>
172
212
  <summary>Default config</summary>
173
213
 
@@ -240,31 +280,31 @@ Define available states and style prefixes
240
280
  - `inner-border-{color}` - Inner border color (inset box shadow, not compatible with `shadow-`)
241
281
  - `shadow-{color}` - Box shadow color (not compatible with `inner-border-`)
242
282
 
283
+ #### Presets variations
284
+ - `bg-{color}-{(10-90)}` - Background opacity
285
+ - `border-{color}-{presetKey}` - Border width
286
+ - `shadow-{color}-{presetKey}` - Box shadow spread
287
+ - `inner-border-{color}-{presetKey}` - Box shadow inset width
288
+
243
289
  #### States
244
290
  - `hover:{utility}` - Apply style on hover
245
291
  - `not-hover:{utility}` - Apply style when not hovering
246
292
 
247
- #### Presets
248
- - `bg-{color}-{(10-90)}` - Background opacity
249
- - `border-{color}-{preset}` - Border width
250
- - `shadow-{color}-{preset}` - Box shadow spread
251
- - `inner-border-{color}-{preset}` - Box shadow inset width
252
-
253
293
  ## Prefix/Declaration relations
254
294
  | prefix | declaration |
255
295
  |--------------|-----------------------------------------------------------------------------|
256
296
  | bg | `background: {color} important;` |
257
297
  | text | `color: {color} important;` |
258
- | border | `border-width: {variation \|\| default} !important; border-color: {color} !important; border-style: solid;` |
259
- | inner-border | `box-shadow: inset {variation \|\| default} {color} !important;` |
260
- | shadow | `box-shadow: {variation \|\| default} {color} !important;` |
298
+ | border | `border-width: {presetValue \|\| default} !important; border-color: {color} !important; border-style: solid;` |
299
+ | inner-border | `box-shadow: inset {presetValue \|\| default} {color} !important;` |
300
+ | shadow | `box-shadow: {presetValue \|\| default} {color} !important;` |
261
301
 
262
302
  ## Architecture
263
303
  ### Core Components
264
304
  - **Vite Plugin**: Handles file watching and build process
265
305
  - **Class Extractor**: Scans files for utility classes
266
306
  - **Rule Generator**: Converts utility classes to CSS rules
267
- - **Configuration System**: WIP - Manages user preferences and presets
307
+ - **Configuration System**: Manages user preferences and presets
268
308
 
269
309
  ### File Structure
270
310
  ```
@@ -285,4 +325,8 @@ Define available states and style prefixes
285
325
 
286
326
  This project was made possible thanks to the support and resources provided by [__Improba__](https://improba.fr/).
287
327
  <br />
288
- Their trust and commitment played a key role in bringing this idea to life, and i'm grateful for their involvement in making it happen.
328
+ Their trust and commitment played a key role in bringing this idea to life, and i'm grateful for their involvement in making it happen.
329
+
330
+ ## Licence
331
+
332
+ This project is licensed under the [MIT License](./LICENSE).
package/index.js CHANGED
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  const { init: initConfig } = require('./dist/config/config.tool');
4
- const { log, logPrefix } = require('./dist/tools/logger');
4
+ const { log, logPrefix, logo } = require('./dist/tools/logger');
5
5
  const { init: initClassExtraction } = require('./dist/tools/extract/classes');
6
6
 
7
7
  /** List every imported colors across the projet */
8
8
  const colors = [];
9
9
 
10
10
  const init = async () => {
11
+ logo();
12
+
11
13
  console.time(`${logPrefix} Config initialized in`);
12
14
  initConfig();
13
15
  console.timeEnd(`${logPrefix} Config initialized in`);
@@ -19,19 +21,29 @@ const init = async () => {
19
21
  log('---');
20
22
  };
21
23
 
24
+ const refresh = async (file) => {
25
+ // console.log({ file });
26
+
27
+ // _ Prevent self change loop
28
+ // todo - add targets / ignore detection
29
+ if (file.endsWith('_anubis.scss')) { return }
30
+ if (file.endsWith('anubis.config.json')) {
31
+ log('Config file changed, restarting...')
32
+ init();
33
+ return
34
+ }
35
+
36
+ console.time(`${logPrefix} Refreshed in`);
37
+ await initClassExtraction();
38
+ console.timeEnd(`${logPrefix} Refreshed in`);
39
+ }
40
+
22
41
  function AnubisUI() {
23
42
  return {
24
43
  name: 'anubis-ui',
25
44
  configureServer(server) {
26
45
  server.watcher.on('change', async (file) => {
27
- console.log({ file });
28
-
29
- // _ Prevent self change loop
30
- if (file.endsWith('_anubis.vue')) { return }
31
-
32
- console.time(`${logPrefix} Refreshed in`);
33
- await initClassExtraction();
34
- console.timeEnd(`${logPrefix} Refreshed in`);
46
+ await refresh(file)
35
47
  });
36
48
  },
37
49
  async buildStart() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anubis-ui",
3
- "version": "1.0.13",
3
+ "version": "1.1.0",
4
4
  "description": "Class-based css generator",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -15,6 +15,7 @@
15
15
  "vue"
16
16
  ],
17
17
  "scripts": {
18
+ "dev": "npm run preinstall; node src/manual/build.js",
18
19
  "build": "tsc",
19
20
  "preinstall": "npm run build"
20
21
  },
@@ -24,7 +25,7 @@
24
25
  "url": "git+https://github.com/HugoLMTY/anubis-ui.git"
25
26
  },
26
27
  "author": "Improba",
27
- "license": "ISC",
28
+ "license": "MIT",
28
29
  "bugs": {
29
30
  "url": "https://github.com/HugoLMTY/anubis-ui/issues"
30
31
  },
@@ -1,10 +1,9 @@
1
- // import fs from 'fs'
2
- // import path from 'path'
1
+ import { readUserConfigFile, userConfig } from "../tools/fileHandling/configFile"
2
+ import { log } from "../tools/logger"
3
+
3
4
  const fs = require('fs')
4
5
  const path = require('path')
5
6
 
6
- import { log } from '../tools/logger'
7
-
8
7
  interface IPreset {
9
8
  [key: string]: string
10
9
  }
@@ -26,8 +25,8 @@ interface IEnvConfig {
26
25
  [key: string]: any
27
26
  }
28
27
 
29
- const configFolder = path.join(__dirname, '..', '..', 'src', 'config');
30
- const configFiles = [
28
+ const anubisConfigFolder = path.join(__dirname, '..', '..', 'src', 'config');
29
+ const anubisConfigFiles = [
31
30
  'files',
32
31
  'colors',
33
32
  'presets',
@@ -46,17 +45,43 @@ const config = {
46
45
  } as IEnvConfig
47
46
 
48
47
  const init = () => {
49
- for (const file of configFiles) {
50
- const filePath = path.join(configFolder, `${file}.config.json`)
48
+ readUserConfigFile()
49
+
50
+ checkUserConfig()
51
51
 
52
- const configContent = fs.readFileSync(filePath, { encoding: 'utf-8' })
52
+ for (const file of anubisConfigFiles) {
53
+ let configToUse = null
53
54
 
54
- config[file as keyof typeof config] = JSON.parse(configContent)
55
+ if (userConfig && userConfig[file]) {
56
+ log(`${file} config found, overriding default.`)
57
+ configToUse = userConfig[file]
58
+ } else {
59
+ const filePath = path.join(anubisConfigFolder, `${file}.config.json`)
60
+ const configContent = fs.readFileSync(filePath, { encoding: 'utf-8' })
61
+
62
+ configToUse = JSON.parse(configContent)
63
+ }
64
+
65
+ config[file as keyof typeof config] = configToUse
55
66
  }
56
67
 
57
68
  return config
58
69
  }
59
70
 
71
+ const checkUserConfig = () => {
72
+
73
+ // todo - also check values
74
+ const userConfigKeys = Object.keys(userConfig)
75
+
76
+ const unknownKeys = userConfigKeys?.filter(key => !anubisConfigFiles.includes(key))
77
+ if (!unknownKeys?.length) { return }
78
+
79
+ log(`${unknownKeys?.length} unknown config keys found in user config file`)
80
+ for (const key of unknownKeys) {
81
+ log(`- ${key}`)
82
+ }
83
+ }
84
+
60
85
  export {
61
86
  init,
62
87
  config
@@ -0,0 +1,3 @@
1
+ const AnubisUI = require('../../index')
2
+
3
+ AnubisUI()?.buildStart()
@@ -1,9 +1,8 @@
1
1
  import { config } from "../../../config/config.tool"
2
- import { buildCssRuleFile } from "../../cssFile"
2
+ import { buildCssRuleFile } from "../../fileHandling/cssFile"
3
3
  import { mapClassesIntoRules } from "../../mapping/mapClassIntoRule"
4
- import { getFiles } from "../extract.tools"
4
+ import { getFiles } from "../../fileHandling/file.tools"
5
5
 
6
- // import fs from 'fs'
7
6
  const fs = require('fs')
8
7
 
9
8
  /** Fetch vue file based on config target patterns */
@@ -0,0 +1,26 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+
4
+ import { log } from '../logger'
5
+
6
+ const userConfigPath = path.join(process.cwd(), 'anubis.config.json')
7
+ let userConfig = null
8
+
9
+ const readUserConfigFile = () => {
10
+ const userConfigExists = fs.existsSync(userConfigPath)
11
+
12
+ if (!userConfigExists) {
13
+ log('No user config file found, using default configuration.')
14
+ return
15
+ }
16
+
17
+ const config = fs.readFileSync(userConfigPath, { encoding: 'utf-8'})
18
+ userConfig = JSON.parse(config)
19
+
20
+ return userConfig
21
+ }
22
+
23
+ export {
24
+ userConfig,
25
+ readUserConfigFile
26
+ }
@@ -1,9 +1,7 @@
1
- // import fs from 'fs'
2
- // import path from 'path'
3
1
  const fs = require('fs')
4
2
  const path = require('path')
5
3
 
6
- import { cssHeader, log } from './logger'
4
+ import { cssHeader, log } from '../logger'
7
5
 
8
6
  const srcDir = path.join(process.cwd(), 'src', 'css')
9
7
  const outputPath = path.join(srcDir, '_anubis.scss')
@@ -1,4 +1,3 @@
1
- // import fg from 'fast-glob'
2
1
  const fg = require('fast-glob')
3
2
 
4
3
  import { IFileConfig } from '../../interfaces/files.interface'
@@ -1,6 +1,8 @@
1
1
  const logPrefix = '☯︎ [ANUBIS]'
2
2
  const log = (str: string) => console.log(`${logPrefix} ${str}`)
3
3
 
4
+ const { version } = require('./../../package.json')
5
+
4
6
  const logo = () => {
5
7
  log(' ___ _ ____ ______ _________')
6
8
  log(' / | / | / / / / / __ )/ _/ ___/')
@@ -14,7 +16,7 @@ const logo = () => {
14
16
  }
15
17
 
16
18
  const cssHeader = `/*!
17
- * * Anubis v.1.0.13
19
+ * * Anubis v.${version}
18
20
  * * Improba
19
21
  * * Released under the MIT License.
20
22
  * */`
package/src/index.ts DELETED
@@ -1,43 +0,0 @@
1
- import { Plugin } from 'vite'
2
-
3
- import { init as initConfig } from './config/config.tool'
4
- import { log, logo, logPrefix } from './tools/logger'
5
- // import { init as initPresets } from './config/'
6
- import { init as initClassExtraction } from './tools/extract/classes'
7
-
8
- /** List every imported colors across the projet */
9
- const colors: string[] = []
10
-
11
- const init = async () => {
12
- console.time(`${logPrefix} Config initialized in`)
13
- initConfig()
14
- console.timeEnd(`${logPrefix} Config initialized in`)
15
- log('---')
16
-
17
- console.time(`${logPrefix} Rules generated in`)
18
- await initClassExtraction()
19
- console.timeEnd(`${logPrefix} Rules generated in`)
20
- log('---')
21
- }
22
-
23
- export default function AnubisUI (): Plugin {
24
- return {
25
- name: 'anubis-ui',
26
- configureServer(server: any) {
27
- server.watcher.on('change', (file: any) => {
28
- console.log({ file })
29
- })
30
- },
31
- async buildStart() {
32
- logo()
33
-
34
- console.time(`${logPrefix} Anubis initialized in`)
35
- await init()
36
- console.timeEnd(`${logPrefix} Anubis initialized in`)
37
- }
38
- }
39
- }
40
-
41
- export {
42
- colors
43
- }
@@ -1,4 +0,0 @@
1
- import AnubisUI from "..";
2
-
3
- //@ts-ignore
4
- AnubisUI()?.buildStart()
@@ -1,5 +0,0 @@
1
- const colors = [
2
- { name: 'primary', color: '#0f84cb' },
3
- { name: 'secondary', color: '#3b5161' },
4
- { name: 'accent', color: '#0f84cb' },
5
- ]