chromalogger 1.1.1 → 1.2.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 +1 -1
- package/README.md +31 -254
- package/chromalog.js +208 -77
- package/index.js +6 -101
- package/package.json +7 -22
- package/.eslintrc.json +0 -18
- package/.prettierrc +0 -9
- package/CONTRIBUTING.md +0 -43
- package/cli.js +0 -87
- package/core/formatters/objectFormatter.js +0 -100
- package/core/loggers/consoleLogger.js +0 -153
- package/core/styles.js +0 -75
- package/core/utils/validate.js +0 -42
- package/test.js +0 -130
- package/utils/chroma.js +0 -42
package/package.json
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chromalogger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A colorful and flexible console logger for Node.js with CLI support",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
7
|
+
"files": [
|
|
8
|
+
"index.js",
|
|
9
|
+
"chromalog.js"
|
|
10
|
+
],
|
|
10
11
|
"scripts": {
|
|
11
|
-
"test": "node
|
|
12
|
-
"test:watch": "nodemon --watch chromalog.js --watch test.js --exec \"npm test\"",
|
|
13
|
-
"lint": "eslint .",
|
|
14
|
-
"test:chroma": "node chromatest.js",
|
|
15
|
-
"test:cli": "node clitest.js",
|
|
16
|
-
"test:all": "npm run test && npm run test:chroma && npm run test:cli",
|
|
17
|
-
"format": "prettier --write .",
|
|
18
|
-
"fix": "eslint --fix .",
|
|
19
|
-
"coverage": "c8 npm test"
|
|
12
|
+
"test": "node demo.js"
|
|
20
13
|
},
|
|
21
14
|
"keywords": [
|
|
22
15
|
"log",
|
|
@@ -48,13 +41,5 @@
|
|
|
48
41
|
},
|
|
49
42
|
"engines": {
|
|
50
43
|
"node": ">=12.0.0"
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"c8": "^10.1.3",
|
|
54
|
-
"eslint": "^8.0.0",
|
|
55
|
-
"eslint-config-prettier": "^10.1.8",
|
|
56
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
57
|
-
"nodemon": "^3.1.11",
|
|
58
|
-
"prettier": "^3.7.3"
|
|
59
44
|
}
|
|
60
45
|
}
|
package/.eslintrc.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"node": true,
|
|
4
|
-
"es2021": true,
|
|
5
|
-
"browser": true
|
|
6
|
-
},
|
|
7
|
-
"extends": ["eslint:recommended", "prettier"],
|
|
8
|
-
"parserOptions": {
|
|
9
|
-
"ecmaVersion": 2021,
|
|
10
|
-
"sourceType": "module"
|
|
11
|
-
},
|
|
12
|
-
"rules": {
|
|
13
|
-
"no-console": "off",
|
|
14
|
-
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
|
|
15
|
-
"prettier/prettier": "error"
|
|
16
|
-
},
|
|
17
|
-
"plugins": ["prettier"]
|
|
18
|
-
}
|
package/.prettierrc
DELETED
package/CONTRIBUTING.md
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# Comment contribuer
|
|
2
|
-
|
|
3
|
-
Merci de votre intérêt pour `logcolor-js` ! Voici comment vous pouvez contribuer au projet.
|
|
4
|
-
|
|
5
|
-
## Signaler un bug
|
|
6
|
-
|
|
7
|
-
Si vous trouvez un bug, merci de créer une issue en suivant ces étapes :
|
|
8
|
-
|
|
9
|
-
1. Vérifiez que le bug n'a pas déjà été signalé
|
|
10
|
-
2. Décrivez le bug de manière claire et concise
|
|
11
|
-
3. Incluez des étapes pour reproduire le bug
|
|
12
|
-
4. Précisez le comportement attendu
|
|
13
|
-
5. Incluez la version de Node.js et du module
|
|
14
|
-
|
|
15
|
-
## Proposer une amélioration
|
|
16
|
-
|
|
17
|
-
1. Créez une issue pour discuter de votre idée
|
|
18
|
-
2. Si l'idée est acceptée, créez une branche pour votre fonctionnalité
|
|
19
|
-
3. Assurez-vous que les tests passent (`npm test`)
|
|
20
|
-
4. Soumettez une pull request
|
|
21
|
-
|
|
22
|
-
## Processus de développement
|
|
23
|
-
|
|
24
|
-
1. Forkez le dépôt
|
|
25
|
-
2. Installez les dépendances : `npm install`
|
|
26
|
-
3. Créez une branche pour votre fonctionnalité : `git checkout -b ma-nouvelle-fonctionnalite`
|
|
27
|
-
4. Faites vos modifications
|
|
28
|
-
5. Lancez les tests : `npm test`
|
|
29
|
-
6. Formatez votre code : `npm run format`
|
|
30
|
-
7. Vérifiez les erreurs de style : `npm run lint`
|
|
31
|
-
8. Poussez vos modifications : `git push origin ma-nouvelle-fonctionnalite`
|
|
32
|
-
9. Créez une Pull Request
|
|
33
|
-
|
|
34
|
-
## Directives de codage
|
|
35
|
-
|
|
36
|
-
- Suivez le style de code existant
|
|
37
|
-
- Écrivez des tests pour les nouvelles fonctionnalités
|
|
38
|
-
- Documentez votre code avec des commentaires clairs
|
|
39
|
-
- Gardez les commits atomiques et bien décrits
|
|
40
|
-
|
|
41
|
-
## Licence
|
|
42
|
-
|
|
43
|
-
En contribuant à ce projet, vous acceptez que vos contributions soient sous la même licence que le projet (MIT).
|
package/cli.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
console.log('Démarrage du CLI...'); // Debug
|
|
4
|
-
|
|
5
|
-
import { createLogger } from './chromalog.js';
|
|
6
|
-
import fs from 'fs';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
|
|
10
|
-
console.log('Chargement des modules terminé'); // Debug
|
|
11
|
-
|
|
12
|
-
function showHelp() {
|
|
13
|
-
const helpText = `
|
|
14
|
-
Utilisation : clog [options] <message>
|
|
15
|
-
|
|
16
|
-
Options :
|
|
17
|
-
--color <couleur> Couleur du texte (red, green, blue, etc.)
|
|
18
|
-
--style <styles> Styles (séparés par des virgules)
|
|
19
|
-
-v, --version Affiche la version
|
|
20
|
-
-h, --help Affiche cette aide
|
|
21
|
-
|
|
22
|
-
Exemples :
|
|
23
|
-
$ npx clog --color red --style bright "Attention !"
|
|
24
|
-
$ npx clog --color green "Opération réussie"
|
|
25
|
-
`;
|
|
26
|
-
console.log(helpText);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function main() {
|
|
30
|
-
console.log('Début de la fonction main'); // Debug
|
|
31
|
-
const args = process.argv.slice(2);
|
|
32
|
-
console.log('Arguments:', args); // Debug
|
|
33
|
-
|
|
34
|
-
// Afficher l'aide
|
|
35
|
-
if (args.length === 0 || args.includes('--help') || args.includes('-h') || args.includes('-V')) {
|
|
36
|
-
return showHelp();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Afficher la version
|
|
40
|
-
if (args.includes('--version') || args.includes('-v')) {
|
|
41
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
42
|
-
const __dirname = path.dirname(__filename);
|
|
43
|
-
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
|
|
44
|
-
return console.log(pkg.version);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Traitement des arguments de couleur et de style
|
|
48
|
-
let messageParts = [];
|
|
49
|
-
let color = 'white';
|
|
50
|
-
let styles = [];
|
|
51
|
-
|
|
52
|
-
for (let i = 0; i < args.length; i++) {
|
|
53
|
-
const arg = args[i];
|
|
54
|
-
|
|
55
|
-
if (arg === '--color' && args[i + 1]) {
|
|
56
|
-
color = args[++i];
|
|
57
|
-
} else if (arg === '--style' && args[i + 1]) {
|
|
58
|
-
styles = args[++i].split(',').map((s) => s.trim());
|
|
59
|
-
} else if (!arg.startsWith('--')) {
|
|
60
|
-
messageParts.push(arg);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const message = messageParts.join(' ');
|
|
65
|
-
|
|
66
|
-
if (!message) {
|
|
67
|
-
console.error('Erreur: Aucun message fourni');
|
|
68
|
-
return showHelp();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
// Créer et utiliser le logger
|
|
73
|
-
const logger = createLogger(color, ...styles);
|
|
74
|
-
logger(message);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error('Erreur:', error.message);
|
|
77
|
-
console.log('\nCouleurs disponibles: red, green, blue, yellow, magenta, cyan, white');
|
|
78
|
-
console.log(
|
|
79
|
-
'Styles disponibles: bright, dim, italic, underline, blink, reverse, hidden, strikethrough'
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Exécuter le CLI
|
|
85
|
-
if (process.argv[1] && process.argv[1].endsWith('cli.js')) {
|
|
86
|
-
main();
|
|
87
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object formatting utilities
|
|
3
|
-
* @module core/formatters/objectFormatter
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { isObject } from '../utils/validate.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Format an object for display
|
|
10
|
-
* @param {Object} obj - Object to format
|
|
11
|
-
* @param {number} [depth=0] - Current depth for indentation
|
|
12
|
-
* @returns {string} Formatted object string
|
|
13
|
-
*/
|
|
14
|
-
export const formatObject = (obj, depth = 0) => {
|
|
15
|
-
const indent = ' '.repeat(depth);
|
|
16
|
-
const nextIndent = ' '.repeat(depth + 1);
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
if (obj === null) return 'null';
|
|
20
|
-
if (obj === undefined) return 'undefined';
|
|
21
|
-
if (!isObject(obj)) return String(obj);
|
|
22
|
-
|
|
23
|
-
const entries = Object.entries(obj);
|
|
24
|
-
if (entries.length === 0) return '{}';
|
|
25
|
-
|
|
26
|
-
// For small objects, keep on one line
|
|
27
|
-
if (entries.every(([_, value]) => !isObject(value) || value === null)) {
|
|
28
|
-
const content = entries
|
|
29
|
-
.map(([key, value]) => `${key}: ${formatValue(value, depth + 1)}`)
|
|
30
|
-
.join(', ');
|
|
31
|
-
return `{ ${content} }`;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// For larger or complex objects, use multiple lines
|
|
35
|
-
const content = entries
|
|
36
|
-
.map(([key, value]) => `${nextIndent}${key}: ${formatValue(value, depth + 1)}`)
|
|
37
|
-
.join(',\n');
|
|
38
|
-
|
|
39
|
-
return `{\n${content}\n${indent}}`;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
return '[Object]';
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Format a value for display
|
|
47
|
-
* @param {*} value - Value to format
|
|
48
|
-
* @param {number} [depth=0] - Current depth for indentation
|
|
49
|
-
* @returns {string} Formatted value
|
|
50
|
-
*/
|
|
51
|
-
const formatValue = (value, depth = 0) => {
|
|
52
|
-
if (value === null) return 'null';
|
|
53
|
-
if (value === undefined) return 'undefined';
|
|
54
|
-
|
|
55
|
-
switch (typeof value) {
|
|
56
|
-
case 'string':
|
|
57
|
-
return `"${value}"`;
|
|
58
|
-
case 'object':
|
|
59
|
-
if (Array.isArray(value)) {
|
|
60
|
-
return formatArray(value, depth);
|
|
61
|
-
}
|
|
62
|
-
return formatObject(value, depth);
|
|
63
|
-
case 'function':
|
|
64
|
-
return '[Function]';
|
|
65
|
-
case 'symbol':
|
|
66
|
-
return value.toString();
|
|
67
|
-
default:
|
|
68
|
-
return String(value);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Format an array for display
|
|
74
|
-
* @param {Array} arr - Array to format
|
|
75
|
-
* @param {number} [depth=0] - Current depth for indentation
|
|
76
|
-
* @returns {string} Formatted array string
|
|
77
|
-
*/
|
|
78
|
-
const formatArray = (arr, depth = 0) => {
|
|
79
|
-
if (!Array.isArray(arr)) return '[]';
|
|
80
|
-
if (arr.length === 0) return '[]';
|
|
81
|
-
|
|
82
|
-
const indent = ' '.repeat(depth);
|
|
83
|
-
const nextIndent = ' '.repeat(depth + 1);
|
|
84
|
-
|
|
85
|
-
// For small arrays, keep on one line
|
|
86
|
-
if (arr.length <= 3 && arr.every((item) => !isObject(item) || item === null)) {
|
|
87
|
-
return `[ ${arr.map((item) => formatValue(item, depth + 1)).join(', ')} ]`;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// For larger or complex arrays, use multiple lines
|
|
91
|
-
const items = arr.map((item) => `${nextIndent}${formatValue(item, depth + 1)}`).join(',\n');
|
|
92
|
-
|
|
93
|
-
return `[\n${items}\n${indent}]`;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export default {
|
|
97
|
-
formatObject,
|
|
98
|
-
formatArray,
|
|
99
|
-
formatValue,
|
|
100
|
-
};
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Console logger implementation
|
|
3
|
-
* @module core/loggers/consoleLogger
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { formatObject } from '../formatters/objectFormatter.js';
|
|
7
|
-
import { validateInput } from '../utils/validate.js';
|
|
8
|
-
import styles from '../styles.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Log levels and their priorities
|
|
12
|
-
* @type {Object}
|
|
13
|
-
*/
|
|
14
|
-
const LOG_LEVELS = {
|
|
15
|
-
DEBUG: 0,
|
|
16
|
-
INFO: 1,
|
|
17
|
-
WARN: 2,
|
|
18
|
-
ERROR: 3,
|
|
19
|
-
NONE: 4,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
let currentLogLevel = LOG_LEVELS.INFO;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Create a logger with the specified styles
|
|
26
|
-
* @param {...string} styleNames - Names of styles to apply
|
|
27
|
-
* @returns {Function} Logger function
|
|
28
|
-
*/
|
|
29
|
-
const createLogger = (...styleNames) => {
|
|
30
|
-
// Get style codes
|
|
31
|
-
const styleCodes = styleNames.map((name) => {
|
|
32
|
-
if (!styles[name]) {
|
|
33
|
-
console.warn(`LogColor: Unknown style "${name}"`);
|
|
34
|
-
return '';
|
|
35
|
-
}
|
|
36
|
-
return styles[name];
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const stylePrefix = styleCodes.join('');
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Logger function
|
|
43
|
-
* @param {...*} args - Arguments to log
|
|
44
|
-
*/
|
|
45
|
-
const logger = (...args) => {
|
|
46
|
-
try {
|
|
47
|
-
// Vérifier le niveau de log
|
|
48
|
-
let logLevel = LOG_LEVELS.INFO;
|
|
49
|
-
if (styleNames.includes('dim')) {
|
|
50
|
-
logLevel = LOG_LEVELS.DEBUG;
|
|
51
|
-
} else if (styleNames.includes('yellow')) {
|
|
52
|
-
logLevel = LOG_LEVELS.WARN;
|
|
53
|
-
} else if (styleNames.includes('red')) {
|
|
54
|
-
logLevel = LOG_LEVELS.ERROR;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (logLevel < currentLogLevel) return;
|
|
58
|
-
|
|
59
|
-
const validArgs = validateInput(args);
|
|
60
|
-
|
|
61
|
-
// Handle template strings
|
|
62
|
-
if (typeof validArgs[0] === 'string' && validArgs.length > 1) {
|
|
63
|
-
const message = formatMessage(validArgs[0], validArgs.slice(1));
|
|
64
|
-
console.log(`${stylePrefix}${message}${styles.reset}`);
|
|
65
|
-
} else {
|
|
66
|
-
// Format each argument
|
|
67
|
-
const formattedArgs = validArgs.map((arg) => {
|
|
68
|
-
if (arg === null) return 'null';
|
|
69
|
-
if (arg === undefined) return 'undefined';
|
|
70
|
-
if (typeof arg === 'object' || Array.isArray(arg)) {
|
|
71
|
-
return formatObject(arg);
|
|
72
|
-
}
|
|
73
|
-
if (typeof arg === 'string') return arg;
|
|
74
|
-
return String(arg);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Handle multi-line output
|
|
78
|
-
const output = formattedArgs.join(' ').split('\n').join('\n ');
|
|
79
|
-
console.log(`${stylePrefix}${output}${styles.reset}`);
|
|
80
|
-
}
|
|
81
|
-
} catch (error) {
|
|
82
|
-
console.error(`${styles.red}LogColor: Logging error - ${error.message}${styles.reset}`);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// Add style methods for method chaining
|
|
87
|
-
Object.keys(styles).forEach((styleName) => {
|
|
88
|
-
Object.defineProperty(logger, styleName, {
|
|
89
|
-
get: () => createLogger(...styleNames, styleName),
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return logger;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Format a message with placeholders
|
|
98
|
-
* @param {string} message - Message with {0}, {1}, etc. placeholders
|
|
99
|
-
* @param {Array} values - Values to replace placeholders
|
|
100
|
-
* @returns {string} Formatted message
|
|
101
|
-
*/
|
|
102
|
-
const formatMessage = (message, values = []) => {
|
|
103
|
-
if (typeof message !== 'string' || !Array.isArray(values)) {
|
|
104
|
-
return String(message);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return message.replace(/\{(\d+)\}/g, (match, index) => {
|
|
108
|
-
const value = values[parseInt(index, 10)];
|
|
109
|
-
if (value === undefined) return match;
|
|
110
|
-
|
|
111
|
-
if (typeof value === 'object' || Array.isArray(value)) {
|
|
112
|
-
return formatObject(value);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return String(value);
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Set the current log level
|
|
121
|
-
* @param {string} level - Log level (DEBUG, INFO, WARN, ERROR, NONE)
|
|
122
|
-
*/
|
|
123
|
-
const setLogLevel = (level) => {
|
|
124
|
-
const upperLevel = level.toUpperCase();
|
|
125
|
-
if (LOG_LEVELS[upperLevel] !== undefined) {
|
|
126
|
-
currentLogLevel = LOG_LEVELS[upperLevel];
|
|
127
|
-
} else {
|
|
128
|
-
console.warn(`LogColor: Unknown log level "${level}". Using INFO.`);
|
|
129
|
-
currentLogLevel = LOG_LEVELS.INFO;
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// Create default loggers
|
|
134
|
-
const log = createLogger();
|
|
135
|
-
const debug = createLogger('dim');
|
|
136
|
-
const info = createLogger('cyan');
|
|
137
|
-
const warn = createLogger('yellow');
|
|
138
|
-
const error = createLogger('red');
|
|
139
|
-
|
|
140
|
-
// Export everything
|
|
141
|
-
export { createLogger, formatMessage, setLogLevel, log, debug, info, warn, error, LOG_LEVELS };
|
|
142
|
-
|
|
143
|
-
export default {
|
|
144
|
-
createLogger,
|
|
145
|
-
formatMessage,
|
|
146
|
-
setLogLevel,
|
|
147
|
-
log,
|
|
148
|
-
debug,
|
|
149
|
-
info,
|
|
150
|
-
warn,
|
|
151
|
-
error,
|
|
152
|
-
LOG_LEVELS,
|
|
153
|
-
};
|
package/core/styles.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ANSI escape codes for colors and styles
|
|
3
|
-
* @module core/styles
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export const styles = {
|
|
7
|
-
// Text colors
|
|
8
|
-
black: '\x1b[30m',
|
|
9
|
-
red: '\x1b[31m',
|
|
10
|
-
green: '\x1b[32m',
|
|
11
|
-
yellow: '\x1b[33m',
|
|
12
|
-
blue: '\x1b[34m',
|
|
13
|
-
magenta: '\x1b[35m',
|
|
14
|
-
cyan: '\x1b[36m',
|
|
15
|
-
white: '\x1b[37m',
|
|
16
|
-
gray: '\x1b[90m',
|
|
17
|
-
|
|
18
|
-
// Background colors
|
|
19
|
-
bgBlack: '\x1b[40m',
|
|
20
|
-
bgRed: '\x1b[41m',
|
|
21
|
-
bgGreen: '\x1b[42m',
|
|
22
|
-
bgYellow: '\x1b[43m',
|
|
23
|
-
bgBlue: '\x1b[44m',
|
|
24
|
-
bgMagenta: '\x1b[45m',
|
|
25
|
-
bgCyan: '\x1b[46m',
|
|
26
|
-
bgWhite: '\x1b[47m',
|
|
27
|
-
|
|
28
|
-
// Text styles
|
|
29
|
-
reset: '\x1b[0m',
|
|
30
|
-
bright: '\x1b[1m',
|
|
31
|
-
dim: '\x1b[2m',
|
|
32
|
-
italic: '\x1b[3m',
|
|
33
|
-
underline: '\x1b[4m',
|
|
34
|
-
blink: '\x1b[5m',
|
|
35
|
-
reverse: '\x1b[7m',
|
|
36
|
-
hidden: '\x1b[8m',
|
|
37
|
-
strikethrough: '\x1b[9m',
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// Aliases for common styles
|
|
41
|
-
export const colors = {
|
|
42
|
-
// Text colors
|
|
43
|
-
black: styles.black,
|
|
44
|
-
red: styles.red,
|
|
45
|
-
green: styles.green,
|
|
46
|
-
yellow: styles.yellow,
|
|
47
|
-
blue: styles.blue,
|
|
48
|
-
magenta: styles.magenta,
|
|
49
|
-
cyan: styles.cyan,
|
|
50
|
-
white: styles.white,
|
|
51
|
-
gray: styles.gray,
|
|
52
|
-
|
|
53
|
-
// Background colors
|
|
54
|
-
bgBlack: styles.bgBlack,
|
|
55
|
-
bgRed: styles.bgRed,
|
|
56
|
-
bgGreen: styles.bgGreen,
|
|
57
|
-
bgYellow: styles.bgYellow,
|
|
58
|
-
bgBlue: styles.bgBlue,
|
|
59
|
-
bgMagenta: styles.bgMagenta,
|
|
60
|
-
bgCyan: styles.bgCyan,
|
|
61
|
-
bgWhite: styles.bgWhite,
|
|
62
|
-
|
|
63
|
-
// Styles
|
|
64
|
-
reset: styles.reset,
|
|
65
|
-
bold: styles.bright,
|
|
66
|
-
dim: styles.dim,
|
|
67
|
-
italic: styles.italic,
|
|
68
|
-
underline: styles.underline,
|
|
69
|
-
blink: styles.blink,
|
|
70
|
-
inverse: styles.reverse,
|
|
71
|
-
hidden: styles.hidden,
|
|
72
|
-
strikethrough: styles.strikethrough,
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default styles;
|
package/core/utils/validate.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Input validation utilities
|
|
3
|
-
* @module core/utils/validate
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Validate input arguments
|
|
8
|
-
* @param {Array} args - Arguments to validate
|
|
9
|
-
* @returns {Array} Validated arguments
|
|
10
|
-
* @throws {Error} If no arguments are provided
|
|
11
|
-
*/
|
|
12
|
-
export const validateInput = (args) => {
|
|
13
|
-
if (args.length === 0) {
|
|
14
|
-
throw new Error('No arguments provided');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return args;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Check if a value is an object (and not null/array)
|
|
22
|
-
* @param {*} value - Value to check
|
|
23
|
-
* @returns {boolean} True if the value is a non-null object and not an array
|
|
24
|
-
*/
|
|
25
|
-
export const isObject = (value) => {
|
|
26
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Check if a value is a plain object
|
|
31
|
-
* @param {*} value - Value to check
|
|
32
|
-
* @returns {boolean} True if the value is a plain object
|
|
33
|
-
*/
|
|
34
|
-
export const isPlainObject = (value) => {
|
|
35
|
-
return isObject(value) && Object.prototype.toString.call(value) === '[object Object]';
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export default {
|
|
39
|
-
validateInput,
|
|
40
|
-
isObject,
|
|
41
|
-
isPlainObject,
|
|
42
|
-
};
|