beathers 5.1.1 → 5.2.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.
@@ -6,14 +6,59 @@ import { BuildScssVariables } from './BuildScssVariables.js';
6
6
  import { CallNewVariables } from './CallNewVariables.js';
7
7
  import { LoadUserConfigs } from './LoadUserConfigs.js';
8
8
  import { DeepMerge } from './Merge.js';
9
+ import { ReadDefaultValues } from './ReadDefaultValues.js';
9
10
  const __filename = fileURLToPath(import.meta.url);
10
11
  const __dirname = path.dirname(__filename);
11
12
  const projectRoot = path.resolve(__dirname, '../..');
12
13
  const variablesPath = path.join(projectRoot, 'src', 'scss', '_variables.scss');
14
+ async function defaultTheme() {
15
+ let values = null;
16
+ try {
17
+ values = await ReadDefaultValues([path.join(projectRoot, 'src', 'scss', 'settings', '_index.scss')], [
18
+ 'useMediaQueries',
19
+ 'useIcons',
20
+ 'useFontFamilies',
21
+ 'useFontSizes',
22
+ 'useFontShapes',
23
+ 'useTextAligns',
24
+ 'useTextTruncate',
25
+ 'useColors',
26
+ 'useColorsOpacities',
27
+ 'useColorsLightMode',
28
+ 'useColorsDarkMode',
29
+ 'useCurrentColors',
30
+ 'useRootColors',
31
+ 'useGrid',
32
+ 'useFlex',
33
+ 'useTransitions',
34
+ 'useWrappers',
35
+ 'useShadows',
36
+ 'useDisplays',
37
+ 'useOverflows',
38
+ 'useOpacities',
39
+ 'useBlur',
40
+ 'useObjectFits',
41
+ 'usePositions',
42
+ 'useInsets',
43
+ 'useSizes',
44
+ 'useGutters',
45
+ 'useBorders',
46
+ 'useTextBorders',
47
+ 'useRadius',
48
+ ]);
49
+ }
50
+ catch (error) {
51
+ // eslint-disable-next-line no-console
52
+ console.error('❌ buildCustomTheme failed:', error instanceof Error ? error.message : error);
53
+ process.exit(1);
54
+ }
55
+ return values;
56
+ }
13
57
  export async function BuildTheme() {
14
58
  try {
59
+ const defaults = await defaultTheme();
15
60
  const userConfigs = await LoadUserConfigs();
16
- const theme = DeepMerge({}, userConfigs);
61
+ const theme = DeepMerge(defaults, userConfigs);
17
62
  const variablesString = BuildScssVariables(theme);
18
63
  await fs.writeFile(variablesPath, variablesString, { flag: 'w' });
19
64
  await CallNewVariables(projectRoot);
@@ -1,4 +1,5 @@
1
1
  import fs from 'fs-extra';
2
+ import { pathToFileURL } from 'node:url';
2
3
  import path from 'path';
3
4
  const userConfigFiles = ['beathers.configs.js', 'beathers.configs.ts', 'beathers.configs.json'];
4
5
  function findConfigFile(basePath) {
@@ -12,8 +13,9 @@ function findConfigFile(basePath) {
12
13
  async function loadJsOrTsConfig(filePath) {
13
14
  try {
14
15
  const absolutePath = path.resolve(filePath);
15
- const module = await import(absolutePath);
16
- return module.default || module;
16
+ const fileUrl = pathToFileURL(absolutePath).href;
17
+ const module = await import(fileUrl);
18
+ return module.default ?? module;
17
19
  }
18
20
  catch (error) {
19
21
  throw new Error(`Failed to load config from ${filePath}: ${error}`);
@@ -29,7 +31,7 @@ function loadJsonConfig(filePath) {
29
31
  }
30
32
  }
31
33
  export async function LoadUserConfigs(projectPath) {
32
- const basePath = projectPath || process.cwd();
34
+ const basePath = projectPath ?? process.cwd();
33
35
  const configFilePath = findConfigFile(basePath);
34
36
  if (!configFilePath)
35
37
  return null;
@@ -62,7 +62,7 @@ function buildWrappers(value) {
62
62
  const raw = value
63
63
  .replace(/\(/g, '{')
64
64
  .replace(/\)/g, '}')
65
- .replace(/([a-zA-Z0-9_]+):\s*([0-9%px]+)\s+([0-9.]+rem)/g, '"$1": {"size": "$2", "padding": "$3"}')
65
+ .replace(/([a-zA-Z0-9_]+):\s*([0-9%px]+)\s+([0-9.]+rem)/g, '"$1": {"width": "$2", "padding": "$3"}')
66
66
  .replace(/,\s*}/g, '}');
67
67
  const parsed = JSON.parse(raw);
68
68
  return parsed;
@@ -118,7 +118,7 @@ async function promptFormat() {
118
118
  const readline = await import('readline');
119
119
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
120
120
  return new Promise((resolve) => {
121
- rl.question('📁 Choose file format (json/js/ts) [json]: ', (answer) => {
121
+ rl.question('📁 Choose file format (json/js/ts): json', (answer) => {
122
122
  rl.close();
123
123
  const format = answer.toLowerCase().trim();
124
124
  if (format === 'js' || format === 'ts')
@@ -134,13 +134,13 @@ async function initCommand() {
134
134
  const fileName = formatMap[format];
135
135
  const filePath = path.join(process.cwd(), fileName);
136
136
  if (await fs.pathExists(filePath)) {
137
- const shouldOverride = await promptUser(`⚠️ ${fileName} already exists. Do you want to override it? (y/n): `);
137
+ const shouldOverride = await promptUser(`⚠️ ${fileName} already exists. Do you want to override it? (Y/N): `);
138
138
  if (!shouldOverride) {
139
139
  console.log('❌ Operation aborted.');
140
140
  return;
141
141
  }
142
142
  }
143
- const includeStarterValues = await promptUser('📝 Would you like to include starter configuration values? (y/n): ');
143
+ const includeStarterValues = await promptUser('📝 Would you like to include starter configuration values? (Y/N): ');
144
144
  const emptyTemplate = {
145
145
  colors: {},
146
146
  typography: {
@@ -1,55 +1,52 @@
1
- export type ColorType = Record<string, {
1
+ type SizeUnit = `${number}px` | `${number}rem` | `${number}em` | `${number}vw` | `${number}vh` | `${number}%`;
2
+ type ColorType = Record<string, {
2
3
  light: `#${string}`;
3
4
  dark: `#${string}`;
4
5
  }>;
5
- export type FontWeight = 'thin' | 'extra-light' | 'light' | 'regular' | 'medium' | 'semibold' | 'bold' | 'extra-bold' | 'black';
6
- export type FontStyle = 'normal' | 'italic' | 'oblique';
7
- export type FontSize = `${number}px` | `${number}rem` | `${number}em`;
8
- export interface FontVariant {
6
+ type FontWeight = 'thin' | 'extra-light' | 'light' | 'regular' | 'medium' | 'semibold' | 'bold' | 'extra-bold' | 'black';
7
+ type FontStyle = 'normal' | 'italic' | 'oblique';
8
+ interface FontVariant {
9
9
  title: string;
10
10
  unicode?: string;
11
11
  format?: 'woff' | 'woff2';
12
12
  isLocal?: boolean;
13
13
  url?: `https://${string}` | `http://${string}`;
14
14
  }
15
- export type FontType = {
15
+ type FontType = {
16
16
  weights?: FontWeight[];
17
17
  styles?: FontStyle[];
18
18
  variants?: Record<string, FontVariant>;
19
19
  };
20
- export interface Typography {
20
+ interface Typography {
21
21
  defaultFontFamilies?: string[];
22
22
  fontMainPath?: string;
23
23
  fontFormat?: 'woff' | 'woff2';
24
24
  fontWeights?: FontWeight[];
25
25
  fontStyles?: FontStyle[];
26
- fontSizes?: Record<string, FontSize>;
26
+ fontSizes?: Record<string, SizeUnit>;
27
27
  textTruncate?: number;
28
28
  fonts?: Record<string, FontType>;
29
29
  }
30
- export type Breakpoints = Record<'sm' | 'md' | 'lg' | 'xl' | 'xxl', `${number}px` | `${number}rem` | `${number}em`>;
31
- export type Wrappers = Record<'sm' | 'md' | 'lg' | 'xl' | 'xxl', {
32
- width: `${number}px` | `${number}rem` | `${number}em`;
33
- padding?: `${number}px` | `${number}rem` | `${number}em`;
34
- }>;
35
- export type GutterValues = Record<'auto' | number, `${number}px` | `${number}rem` | `${number}em`>;
36
- export interface Settings {
30
+ interface Settings {
37
31
  axisDivisions?: number;
38
32
  opacities?: number[];
39
33
  blurValues?: number[];
40
34
  insetValues?: number[];
41
35
  bordersValue?: number;
42
36
  radiuses?: number[];
43
- breakpoints?: Breakpoints;
44
- wrappers?: Wrappers;
45
- guttersValues?: GutterValues;
37
+ breakpoints?: Record<'null' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl', 0 | SizeUnit>;
38
+ wrappers?: Record<'null' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl', {
39
+ width: SizeUnit;
40
+ padding?: SizeUnit;
41
+ }>;
42
+ guttersValues?: Record<'auto' | number, 'auto' | SizeUnit>;
46
43
  }
47
44
  type RoleKeys = 'useMediaQueries' | 'useIcons' | 'useFontFamilies' | 'useFontSizes' | 'useFontShapes' | 'useTextAligns' | 'useTextTruncate' | 'useColors' | 'useColorsOpacities' | 'useColorsLightMode' | 'useColorsDarkMode' | 'useCurrentColors' | 'useRootColors' | 'useGrid' | 'useFlex' | 'useTransitions' | 'useWrappers' | 'useShadows' | 'useDisplays' | 'useOverflows' | 'useOpacities' | 'useBlur' | 'useObjectFits' | 'usePositions' | 'useInsets' | 'useSizes' | 'useGutters' | 'useBorders' | 'useTextBorders' | 'useRadius';
48
- export type Roles = Partial<Record<RoleKeys, boolean>>;
49
- export interface Theme {
45
+ type Roles = Partial<Record<RoleKeys, boolean>>;
46
+ interface Theme {
50
47
  colors?: ColorType;
51
48
  typography?: Typography;
52
49
  settings?: Settings;
53
50
  roles?: Roles;
54
51
  }
55
- export {};
52
+ export type { SizeUnit, ColorType, FontWeight, FontStyle, FontVariant, FontType, Typography, Settings, RoleKeys, Roles, Theme, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beathers",
3
- "version": "5.1.1",
3
+ "version": "5.2.1",
4
4
  "type": "module",
5
5
  "description": "Beather is a lightweight SCSS library that serves as a comprehensive design system for your projects. It offers a structured and consistent approach to manage colors, fonts, and other design related variables, making it easier to maintain a cohesive visual identity across your application.",
6
6
  "main": "dist/index.js",
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Beathers v5.1.1 (https://bhoenixstudio.com/beathers)
2
+ * Beathers v5.2.1 (https://bhoenixstudio.com/beathers)
3
3
  * Copyright 2020-2025 Bhoenix Studio
4
4
  */
5
5