anubis-ui 1.2.20 → 1.2.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anubis-ui",
3
- "version": "1.2.20",
3
+ "version": "1.2.22",
4
4
  "description": "Class-based css generator",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "dev": "rm -rf dist; npm run prepare; node src/manual/build.js",
19
- "build": "tsc && tsc-alias",
19
+ "build": "node scripts/generate-version.js && tsc && tsc-alias",
20
20
  "preinstall": "npm run build",
21
21
  "prepare": "npm run build",
22
22
  "test": "vitest",
@@ -0,0 +1,15 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
5
+ const versionFilePath = path.join(__dirname, '..', 'src', 'version.ts');
6
+
7
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
8
+ const versionCode = `// This file is auto-generated by scripts/generate-version.js
9
+ // Do not edit this file manually
10
+
11
+ export const version = '${packageJson.version}';
12
+ export default { version };
13
+ `;
14
+
15
+ fs.writeFileSync(versionFilePath, versionCode, 'utf-8');
@@ -1,4 +1,4 @@
1
- import packageJson from '../../package.json';
1
+ import { version } from '../version';
2
2
 
3
3
  const logPrefix = '☯︎ [ANUBIS]'
4
4
  const log = (str: string) => console.log(`${logPrefix} ${str}`)
@@ -10,7 +10,7 @@ const logo = () => {
10
10
  log(' / ___ |/ /| / /_/ / /_/ // / ___/ /')
11
11
  log('/_/ |_/_/ |_/\\____/_____/___//____/')
12
12
  log('')
13
- log(`Welcome to Anubis v${packageJson.version}`)
13
+ log(`Welcome to Anubis v${version}`)
14
14
  log('Autonomous Nominative Utility Based Intuitive Styler')
15
15
  log('---')
16
16
  }
@@ -35,25 +35,18 @@ const generateCssRules = (ruleInfos: IRuleInfo[]): string => {
35
35
 
36
36
  const mapClassIntoRule = (stringClass: string): IRuleInfo | null => {
37
37
  const params = getClassInfos(stringClass);
38
+ if (!params.utility) { return null }
38
39
 
39
- /**
40
- * _ If no variations are found, maybe it's just a color like bg-primary
41
- * _ So we need to check if the color exists to avoid useless computing
42
- * */
43
- if (!params.utility) {
44
- const { colorExists } = getColorInfos(params.color);
45
-
46
- if (!colorExists) {
47
- return null;
48
- }
49
- }
40
+ const needsColor = params.utility?.declaration?.includes('${color}')
41
+ const usesVariation = params.variationName
42
+ const hasDefaultVariation = Object.keys(params.utility?.variations || []).includes('default')
50
43
 
51
44
  /**
52
- * _ If the current QoL isn't standalone and doesn't have a variation (can be called without variation)
53
- * _ then no
54
- */
55
- if (!params.color && !Object.keys(params.utility?.variations || []).includes('default') && !params.variationName) {
56
- return null;
45
+ * If need color but doesn't have one or if need a variation but doesn't have one either
46
+ * this is a no go
47
+ */
48
+ if ((needsColor && !params.color) || (!hasDefaultVariation && !usesVariation)) {
49
+ return null
57
50
  }
58
51
 
59
52
  const ruleInfo = buildRuleInfo(params);
@@ -165,7 +158,7 @@ const getUtilityInfos = ({
165
158
  }
166
159
 
167
160
  if (!matchingUtility) {
168
- log(`No utility found for ${cleanedColor || prefix}`);
161
+ // log(`No utility found for ${cleanedColor || prefix}`);
169
162
 
170
163
  return {
171
164
  matchingUtility,
@@ -174,7 +167,7 @@ const getUtilityInfos = ({
174
167
  }
175
168
 
176
169
  if (!colorExists && !matchingUtility.variations) {
177
- log(`Unknow stuff -> ${[prefix, cleanedColor].join('-')}`);
170
+ // log(`Unknow stuff -> ${[prefix, cleanedColor].join('-')}`);
178
171
 
179
172
  return {
180
173
  matchingUtility,
@@ -328,7 +321,6 @@ const getColorInfos = (color: string) => {
328
321
  const colorExists = Object.keys(config.colors).some(
329
322
  configColor => configColor === baseColor
330
323
  );
331
- color === 'primary-10' && console.log({ colorExists, baseColor })
332
324
 
333
325
  return {
334
326
  colorExists,
@@ -1,5 +1,4 @@
1
- import packageJson from '../../../package.json';
2
- const { version } = packageJson;
1
+ import { version } from '../../version';
3
2
 
4
3
  const header = `/**
5
4
  * Anubis v.${version}
package/tsconfig.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "outDir": "./dist",
4
+ "rootDir": "./src",
4
5
  "declaration": true,
5
6
  "module": "commonjs",
6
7
  "target": "es2019",
@@ -16,6 +17,6 @@
16
17
  "@validation/*": ["./tools/validation/*"]
17
18
  }
18
19
  },
19
- "include": ["src/**/*", "package.json"],
20
+ "include": ["src/**/*"],
20
21
  "exclude": ["node_modules", "dist"]
21
22
  }