beathers 5.0.0 ā 5.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/dist/css/beathers.min.css +1 -1
- package/dist/css/beathers.min.css.map +1 -1
- package/dist/scripts/BuildTheme.js +5 -74
- package/dist/scripts/cli.js +209 -1
- package/dist/scripts/types.d.ts +2 -4
- package/package.json +28 -32
- package/public/images/logo.png +0 -0
- package/readme.md +132 -150
- package/src/scss/beathers.min.scss +8 -8
|
@@ -1,99 +1,30 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
1
2
|
import fs from 'fs-extra';
|
|
2
3
|
import * as path from 'node:path';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { LoadUserConfigs } from './LoadUserConfigs.js';
|
|
5
|
-
import { DeepMerge } from './Merge.js';
|
|
6
|
-
import { ReadDefaultValues } from './ReadDefaultValues.js';
|
|
7
5
|
import { BuildScssVariables } from './BuildScssVariables.js';
|
|
8
6
|
import { CallNewVariables } from './CallNewVariables.js';
|
|
7
|
+
import { LoadUserConfigs } from './LoadUserConfigs.js';
|
|
8
|
+
import { DeepMerge } from './Merge.js';
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
10
|
const __dirname = path.dirname(__filename);
|
|
11
11
|
const projectRoot = path.resolve(__dirname, '../..');
|
|
12
12
|
const variablesPath = path.join(projectRoot, 'src', 'scss', '_variables.scss');
|
|
13
|
-
async function defaultTheme() {
|
|
14
|
-
let values = null;
|
|
15
|
-
try {
|
|
16
|
-
values = await ReadDefaultValues([
|
|
17
|
-
path.join(projectRoot, 'src', 'scss', 'settings', '_defaults.scss'),
|
|
18
|
-
path.join(projectRoot, 'src', 'scss', 'settings', '_configs.scss'),
|
|
19
|
-
path.join(projectRoot, 'src', 'scss', 'settings', '_index.scss'),
|
|
20
|
-
], [
|
|
21
|
-
'colors',
|
|
22
|
-
'fonts',
|
|
23
|
-
'fontMainPath',
|
|
24
|
-
'fontFormat',
|
|
25
|
-
'fontWeights',
|
|
26
|
-
'fontStyles',
|
|
27
|
-
'textTruncate',
|
|
28
|
-
'defaultFontFamilies',
|
|
29
|
-
'fontSizes',
|
|
30
|
-
'axisDivisions',
|
|
31
|
-
'breakpoints',
|
|
32
|
-
'wrappers',
|
|
33
|
-
'opacities',
|
|
34
|
-
'blurValues',
|
|
35
|
-
'insetValues',
|
|
36
|
-
'guttersValues',
|
|
37
|
-
'bordersValue',
|
|
38
|
-
'radiuses',
|
|
39
|
-
'useMediaQueries',
|
|
40
|
-
'useIcons',
|
|
41
|
-
'useFontFamilies',
|
|
42
|
-
'useFontSizes',
|
|
43
|
-
'useFontShapes',
|
|
44
|
-
'useTextAligns',
|
|
45
|
-
'useTextTruncate',
|
|
46
|
-
'useColors',
|
|
47
|
-
'useColorsOpacities',
|
|
48
|
-
'useColorsLightMode',
|
|
49
|
-
'useColorsDarkMode',
|
|
50
|
-
'useCurrentColors',
|
|
51
|
-
'useRootColors',
|
|
52
|
-
'useGrid',
|
|
53
|
-
'useFlex',
|
|
54
|
-
'useTransitions',
|
|
55
|
-
'useWrappers',
|
|
56
|
-
'useShadows',
|
|
57
|
-
'useDisplays',
|
|
58
|
-
'useOverflows',
|
|
59
|
-
'useOpacities',
|
|
60
|
-
'useBlur',
|
|
61
|
-
'useObjectFits',
|
|
62
|
-
'usePositions',
|
|
63
|
-
'useInsets',
|
|
64
|
-
'useSizes',
|
|
65
|
-
'useGutters',
|
|
66
|
-
'useBorders',
|
|
67
|
-
'useTextBorders',
|
|
68
|
-
'useRadius',
|
|
69
|
-
]);
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
// eslint-disable-next-line no-console
|
|
73
|
-
console.error('ā buildCustomTheme failed:', error instanceof Error ? error.message : error);
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
return values;
|
|
77
|
-
}
|
|
78
13
|
export async function BuildTheme() {
|
|
79
14
|
try {
|
|
80
|
-
const defaults = await defaultTheme();
|
|
81
15
|
const userConfigs = await LoadUserConfigs();
|
|
82
|
-
const theme = DeepMerge(
|
|
16
|
+
const theme = DeepMerge({}, userConfigs);
|
|
83
17
|
const variablesString = BuildScssVariables(theme);
|
|
84
18
|
await fs.writeFile(variablesPath, variablesString, { flag: 'w' });
|
|
85
19
|
await CallNewVariables(projectRoot);
|
|
86
20
|
}
|
|
87
21
|
catch (error) {
|
|
88
|
-
// eslint-disable-next-line no-console
|
|
89
22
|
console.error('Error during custom theme build:', error);
|
|
90
23
|
throw error;
|
|
91
24
|
}
|
|
92
25
|
}
|
|
93
|
-
|
|
94
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
26
|
+
if (import.meta.url === `file://${process.argv[1]}`)
|
|
95
27
|
BuildTheme().catch((error) => {
|
|
96
28
|
console.error(error);
|
|
97
29
|
process.exit(1);
|
|
98
30
|
});
|
|
99
|
-
}
|
package/dist/scripts/cli.js
CHANGED
|
@@ -1,6 +1,195 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import path from 'path';
|
|
2
5
|
import { BuildTheme } from './BuildTheme.js';
|
|
3
|
-
|
|
6
|
+
import { ReadDefaultValues } from './ReadDefaultValues.js';
|
|
7
|
+
const commands = {
|
|
8
|
+
build: { description: 'Build theme from configuration files', examples: ['beathers build'] },
|
|
9
|
+
init: { description: 'Initialize beathers configuration file', examples: ['beathers init'] },
|
|
10
|
+
version: { description: 'Show version information', examples: ['beathers -v', 'beathers --version'] },
|
|
11
|
+
help: { description: 'Show help information', examples: ['beathers --help'] },
|
|
12
|
+
};
|
|
13
|
+
function showHelp() {
|
|
14
|
+
console.log('\nšØ Beathers CLI - Design System Builder\n');
|
|
15
|
+
const table = [
|
|
16
|
+
['Command', 'Description', 'Examples'],
|
|
17
|
+
['-------', '-----------', '--------'],
|
|
18
|
+
];
|
|
19
|
+
Object.entries(commands).forEach(([cmd, info]) => {
|
|
20
|
+
table.push([cmd, info.description, info.examples[0]]);
|
|
21
|
+
if (info.examples.length > 1) {
|
|
22
|
+
info.examples.slice(1).forEach((example) => {
|
|
23
|
+
table.push(['', '', example]);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const maxLengths = table[0].map((_, colIndex) => Math.max(...table.map((row) => row[colIndex].length)));
|
|
28
|
+
table.forEach((row) => {
|
|
29
|
+
const formattedRow = row.map((cell, colIndex) => cell.padEnd(maxLengths[colIndex])).join(' ');
|
|
30
|
+
console.log(formattedRow);
|
|
31
|
+
});
|
|
32
|
+
console.log('\nFlags:');
|
|
33
|
+
console.log(' --help Show this help message');
|
|
34
|
+
console.log(' -v, --version Show version information');
|
|
35
|
+
console.log();
|
|
36
|
+
}
|
|
37
|
+
function showVersion() {
|
|
38
|
+
const packagePath = path.join(process.cwd(), 'package.json');
|
|
39
|
+
try {
|
|
40
|
+
const packageInfo = fs.readJsonSync(packagePath);
|
|
41
|
+
console.log(`Beathers v${packageInfo.version}`);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
console.log('Beathers CLI');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function getDefaultValues() {
|
|
48
|
+
const projectRoot = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..', '..');
|
|
49
|
+
return (await ReadDefaultValues([
|
|
50
|
+
path.join(projectRoot, 'src', 'scss', 'settings', '_defaults.scss'),
|
|
51
|
+
path.join(projectRoot, 'src', 'scss', 'settings', '_configs.scss'),
|
|
52
|
+
path.join(projectRoot, 'src', 'scss', 'settings', '_index.scss'),
|
|
53
|
+
], [
|
|
54
|
+
'colors',
|
|
55
|
+
'fonts',
|
|
56
|
+
'fontMainPath',
|
|
57
|
+
'fontFormat',
|
|
58
|
+
'fontWeights',
|
|
59
|
+
'fontStyles',
|
|
60
|
+
'textTruncate',
|
|
61
|
+
'defaultFontFamilies',
|
|
62
|
+
'fontSizes',
|
|
63
|
+
'axisDivisions',
|
|
64
|
+
'breakpoints',
|
|
65
|
+
'wrappers',
|
|
66
|
+
'opacities',
|
|
67
|
+
'blurValues',
|
|
68
|
+
'insetValues',
|
|
69
|
+
'guttersValues',
|
|
70
|
+
'bordersValue',
|
|
71
|
+
'radiuses',
|
|
72
|
+
'useMediaQueries',
|
|
73
|
+
'useIcons',
|
|
74
|
+
'useFontFamilies',
|
|
75
|
+
'useFontSizes',
|
|
76
|
+
'useFontShapes',
|
|
77
|
+
'useTextAligns',
|
|
78
|
+
'useTextTruncate',
|
|
79
|
+
'useColors',
|
|
80
|
+
'useColorsOpacities',
|
|
81
|
+
'useColorsLightMode',
|
|
82
|
+
'useColorsDarkMode',
|
|
83
|
+
'useCurrentColors',
|
|
84
|
+
'useRootColors',
|
|
85
|
+
'useGrid',
|
|
86
|
+
'useFlex',
|
|
87
|
+
'useTransitions',
|
|
88
|
+
'useWrappers',
|
|
89
|
+
'useShadows',
|
|
90
|
+
'useDisplays',
|
|
91
|
+
'useOverflows',
|
|
92
|
+
'useOpacities',
|
|
93
|
+
'useBlur',
|
|
94
|
+
'useObjectFits',
|
|
95
|
+
'usePositions',
|
|
96
|
+
'useInsets',
|
|
97
|
+
'useSizes',
|
|
98
|
+
'useGutters',
|
|
99
|
+
'useBorders',
|
|
100
|
+
'useTextBorders',
|
|
101
|
+
'useRadius',
|
|
102
|
+
]));
|
|
103
|
+
}
|
|
104
|
+
async function promptUser(question) {
|
|
105
|
+
const readline = await import('readline');
|
|
106
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
107
|
+
return new Promise((resolve) => {
|
|
108
|
+
rl.question(question, (answer) => {
|
|
109
|
+
rl.close();
|
|
110
|
+
resolve(answer.toLowerCase().startsWith('y'));
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
async function promptFormat() {
|
|
115
|
+
const readline = await import('readline');
|
|
116
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
117
|
+
return new Promise((resolve) => {
|
|
118
|
+
rl.question('š Choose file format (json/js/ts) [json]: ', (answer) => {
|
|
119
|
+
rl.close();
|
|
120
|
+
const format = answer.toLowerCase().trim();
|
|
121
|
+
if (format === 'js' || format === 'ts')
|
|
122
|
+
resolve(format);
|
|
123
|
+
else
|
|
124
|
+
resolve('json');
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async function initCommand() {
|
|
129
|
+
const format = await promptFormat();
|
|
130
|
+
const formatMap = { json: 'beathers.configs.json', js: 'beathers.configs.js', ts: 'beathers.configs.ts' };
|
|
131
|
+
const fileName = formatMap[format];
|
|
132
|
+
const filePath = path.join(process.cwd(), fileName);
|
|
133
|
+
if (await fs.pathExists(filePath)) {
|
|
134
|
+
const shouldOverride = await promptUser(`ā ļø ${fileName} already exists. Do you want to override it? (y/n): `);
|
|
135
|
+
if (!shouldOverride) {
|
|
136
|
+
console.log('ā Operation aborted.');
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const includeStarterValues = await promptUser('š Would you like to include starter configuration values? (y/n): ');
|
|
141
|
+
const emptyTemplate = {
|
|
142
|
+
colors: {},
|
|
143
|
+
typography: {
|
|
144
|
+
defaultFontFamilies: [],
|
|
145
|
+
fontMainPath: '',
|
|
146
|
+
fontFormat: '',
|
|
147
|
+
fontWeights: [],
|
|
148
|
+
fontStyles: [],
|
|
149
|
+
fontSizes: {},
|
|
150
|
+
textTruncate: 0,
|
|
151
|
+
fonts: {},
|
|
152
|
+
},
|
|
153
|
+
settings: {
|
|
154
|
+
axisDivisions: 0,
|
|
155
|
+
opacities: [],
|
|
156
|
+
blurValues: [],
|
|
157
|
+
insetValues: [],
|
|
158
|
+
bordersValue: 0,
|
|
159
|
+
radiuses: [],
|
|
160
|
+
breakpoints: {},
|
|
161
|
+
wrappers: {},
|
|
162
|
+
guttersValues: {},
|
|
163
|
+
},
|
|
164
|
+
roles: {},
|
|
165
|
+
};
|
|
166
|
+
let content = '';
|
|
167
|
+
if (format === 'json') {
|
|
168
|
+
const data = includeStarterValues ? await getDefaultValues() : emptyTemplate;
|
|
169
|
+
content = JSON.stringify(data, null, 2);
|
|
170
|
+
}
|
|
171
|
+
else if (format === 'js') {
|
|
172
|
+
if (includeStarterValues) {
|
|
173
|
+
const defaultValues = await getDefaultValues();
|
|
174
|
+
content = `export default ${JSON.stringify(defaultValues, null, 2)}`;
|
|
175
|
+
}
|
|
176
|
+
else
|
|
177
|
+
content = `export default ${JSON.stringify(emptyTemplate, null, 2)}`;
|
|
178
|
+
}
|
|
179
|
+
else if (format === 'ts') {
|
|
180
|
+
const importLine = "import { Theme } from 'beathers'\n\n";
|
|
181
|
+
if (includeStarterValues) {
|
|
182
|
+
const defaultValues = await getDefaultValues();
|
|
183
|
+
content = `${importLine}export default ${JSON.stringify(defaultValues, null, 2)} satisfies Theme`;
|
|
184
|
+
}
|
|
185
|
+
else
|
|
186
|
+
content = `${importLine}export default ${JSON.stringify(emptyTemplate, null, 2)} satisfies Theme`;
|
|
187
|
+
}
|
|
188
|
+
await fs.writeFile(filePath, content);
|
|
189
|
+
const starterText = includeStarterValues ? ' with starter configuration values' : '';
|
|
190
|
+
console.log(`ā
Created ${fileName}${starterText}`);
|
|
191
|
+
}
|
|
192
|
+
async function buildCommand() {
|
|
4
193
|
try {
|
|
5
194
|
console.log('šØ Building Beathers theme...');
|
|
6
195
|
await BuildTheme();
|
|
@@ -11,4 +200,23 @@ async function main() {
|
|
|
11
200
|
process.exit(1);
|
|
12
201
|
}
|
|
13
202
|
}
|
|
203
|
+
async function main() {
|
|
204
|
+
const args = process.argv.slice(2);
|
|
205
|
+
if (args.length === 0 || args[0] === 'build') {
|
|
206
|
+
await buildCommand();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const command = args[0];
|
|
210
|
+
if (command === 'init')
|
|
211
|
+
await initCommand();
|
|
212
|
+
else if (command === '--help')
|
|
213
|
+
showHelp();
|
|
214
|
+
else if (['-v', '--version'].includes(command))
|
|
215
|
+
showVersion();
|
|
216
|
+
else {
|
|
217
|
+
console.error(`ā Unknown command: ${command}`);
|
|
218
|
+
console.log('\nUse "beathers --help" to see available commands.');
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
14
222
|
main();
|
package/dist/scripts/types.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface FontVariant {
|
|
|
15
15
|
export type FontType = {
|
|
16
16
|
weights?: FontWeight[];
|
|
17
17
|
styles?: FontStyle[];
|
|
18
|
-
variants?: FontVariant
|
|
18
|
+
variants?: Record<string, FontVariant>;
|
|
19
19
|
};
|
|
20
20
|
export interface Typography {
|
|
21
21
|
defaultFontFamilies?: string[];
|
|
@@ -23,9 +23,7 @@ export interface Typography {
|
|
|
23
23
|
fontFormat?: 'woff' | 'woff2';
|
|
24
24
|
fontWeights?: FontWeight[];
|
|
25
25
|
fontStyles?: FontStyle[];
|
|
26
|
-
fontSizes?:
|
|
27
|
-
[sizeName: string]: FontSize;
|
|
28
|
-
};
|
|
26
|
+
fontSizes?: Record<string, FontSize>;
|
|
29
27
|
textTruncate?: number;
|
|
30
28
|
fonts?: Record<string, FontType>;
|
|
31
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beathers",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
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",
|
|
@@ -9,45 +9,40 @@
|
|
|
9
9
|
"beathers": "dist/scripts/cli.js"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"watch": "nodemon --watch src/scss/ --ext scss --exec \"npm-run-all build\"",
|
|
13
|
-
"
|
|
14
|
-
"build": "sass --style
|
|
15
|
-
"build:
|
|
16
|
-
"
|
|
17
|
-
"build:lib": "tsc",
|
|
18
|
-
"build:all": "rimraf dist && npm run build:lib && npm run build",
|
|
19
|
-
"build:with-configs": "tsx src/scripts/BuildTheme.ts",
|
|
20
|
-
"watch:with-configs": "nodemon --watch src --ext ts --exec \"tsx src/scripts/BuildTheme.ts\"",
|
|
21
|
-
"prepublishOnly": "npm run build:all",
|
|
12
|
+
"watch": "nodemon --watch src/scss/ --ext scss --exec \"npm-run-all build:expanded\"",
|
|
13
|
+
"build:compressed": "sass --style compressed --source-map --embed-sources --no-error-css src/scss/:dist/css/",
|
|
14
|
+
"build:expanded": "sass --style expanded --source-map --embed-sources --no-error-css src/scss/:dist/css/",
|
|
15
|
+
"build:user-configs": "tsx src/scripts/BuildTheme.ts",
|
|
16
|
+
"prepublish": "rimraf dist && tsc && pnpm build:compressed",
|
|
22
17
|
"lint": "eslint . && stylelint \"**/*.scss\"",
|
|
23
|
-
"lint:fix": "eslint . --fix && stylelint \"**/*.scss\" --fix",
|
|
24
|
-
"lint:scss": "stylelint \"**/*.scss\"",
|
|
25
|
-
"lint:scss:fix": "stylelint \"**/*.scss\" --fix",
|
|
26
18
|
"format:check": "prettier --check --ignore-path .gitignore .",
|
|
27
19
|
"format:fix": "prettier --write --ignore-path .gitignore . && pnpm lint"
|
|
28
20
|
},
|
|
29
21
|
"keywords": [
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
22
|
+
"design-system",
|
|
23
|
+
"scss-library",
|
|
24
|
+
"css-framework",
|
|
25
|
+
"utility-first",
|
|
26
|
+
"responsive-design",
|
|
27
|
+
"dark-mode",
|
|
28
|
+
"light-mode",
|
|
29
|
+
"theming",
|
|
30
|
+
"css-variables",
|
|
31
|
+
"typography",
|
|
32
|
+
"flexbox",
|
|
33
|
+
"css-grid",
|
|
34
|
+
"media-queries",
|
|
35
|
+
"atomic-css",
|
|
36
|
+
"modular-css",
|
|
37
|
+
"frontend-framework",
|
|
38
|
+
"scalable-css",
|
|
39
|
+
"customizable-theme",
|
|
40
|
+
"component-library",
|
|
41
|
+
"ui-framework"
|
|
40
42
|
],
|
|
41
43
|
"author": "Bhoenix studio",
|
|
42
44
|
"license": "MIT",
|
|
43
|
-
"
|
|
44
|
-
"type": "git",
|
|
45
|
-
"url": "git+https://github.com/BhoenixStudio/Beathers.git"
|
|
46
|
-
},
|
|
47
|
-
"bugs": {
|
|
48
|
-
"url": "https://github.com/BhoenixStudio/Beathers/issues"
|
|
49
|
-
},
|
|
50
|
-
"homepage": "https://github.com/BhoenixStudio/Beathers#readme",
|
|
45
|
+
"homepage": "https://bhoenixstudio.com/beathers",
|
|
51
46
|
"dependencies": {
|
|
52
47
|
"fs-extra": "^11.3.0"
|
|
53
48
|
},
|
|
@@ -79,6 +74,7 @@
|
|
|
79
74
|
"dist/css/**/*.{css,map}",
|
|
80
75
|
"dist/**/*.{js,d.ts}",
|
|
81
76
|
"src/scss/**/*.scss",
|
|
77
|
+
"public/images/logo.png",
|
|
82
78
|
"readme.md"
|
|
83
79
|
]
|
|
84
80
|
}
|
|
Binary file
|