Comparing version 2.10.1 to 3.0.0
@@ -9,3 +9,3 @@ #!/usr/bin/env node | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -12,0 +12,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
{ | ||
"name": "3D", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -29,2 +29,3 @@ "colors": 2, | ||
], | ||
"letterspace_size": 1, | ||
"chars": { | ||
@@ -31,0 +32,0 @@ "A": [ |
{ | ||
"name": "block", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -23,2 +23,3 @@ "colors": 2, | ||
], | ||
"letterspace_size": 1, | ||
"chars": { | ||
@@ -25,0 +26,0 @@ "A": [ |
{ | ||
"name": "chrome", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -16,3 +16,4 @@ "colors": 3, | ||
" " | ||
], | ||
], | ||
"letterspace_size": 1, | ||
"chars": { | ||
@@ -19,0 +20,0 @@ "A": [ |
{ | ||
"name": "grid", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -23,2 +23,3 @@ "colors": 2, | ||
], | ||
"letterspace_size": 1, | ||
"chars": { | ||
@@ -25,0 +26,0 @@ "A": [ |
{ | ||
"name": "huge", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -32,3 +32,4 @@ "colors": 2, | ||
" " | ||
], | ||
], | ||
"letterspace_size": 1, | ||
"chars": { | ||
@@ -35,0 +36,0 @@ "A": [ |
{ | ||
"name": "pallet", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -23,2 +23,3 @@ "colors": 2, | ||
], | ||
"letterspace_size": 1, | ||
"chars": { | ||
@@ -25,0 +26,0 @@ "A": [ |
{ | ||
"name": "shade", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -27,2 +27,3 @@ "colors": 2, | ||
], | ||
"letterspace_size": 1, | ||
"chars": { | ||
@@ -29,0 +30,0 @@ "A": [ |
{ | ||
"name": "simple", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -19,2 +19,3 @@ "colors": 1, | ||
], | ||
"letterspace_size": 1, | ||
"chars": { | ||
@@ -21,0 +22,0 @@ "A": [ |
{ | ||
"name": "simple3d", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -25,2 +25,3 @@ "colors": 1, | ||
], | ||
"letterspace_size": 0, | ||
"chars": { | ||
@@ -27,0 +28,0 @@ "A": [ |
{ | ||
"name": "simpleBlock", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -24,3 +24,4 @@ "colors": 1, | ||
" " | ||
], | ||
], | ||
"letterspace_size": 1, | ||
"chars": { | ||
@@ -27,0 +28,0 @@ "A": [ |
{ | ||
"name": "slick", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -23,2 +23,3 @@ "colors": 2, | ||
], | ||
"letterspace_size": 1, | ||
"chars": { | ||
@@ -25,0 +26,0 @@ "A": [ |
{ | ||
"name": "tiny", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -14,3 +14,4 @@ "colors": 1, | ||
" " | ||
], | ||
], | ||
"letterspace_size": 1, | ||
"chars": { | ||
@@ -17,0 +18,0 @@ "A": [ |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -46,3 +46,3 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
// calculate the size for center alignment | ||
space = Math.floor((size.width - lineLength) / 2); | ||
space = Math.ceil((size.width - lineLength) / 2); | ||
Debugging.report(`AlignText: Center lineLength: ${lineLength}, size.width: ${size.width}, space: ${space}`, 2); | ||
@@ -49,0 +49,0 @@ } |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -37,3 +37,3 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
for (let i = 0; i < fontLines; i++) { | ||
let char = character[i].replace(/(<([^>]+)>)/ig, ''); // get character and strip color infos | ||
let char = character[i].replace(/(<([^>]+)>)/gi, ''); // get character and strip color infos | ||
@@ -40,0 +40,0 @@ if (char.length > charWidth) { |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -19,4 +19,5 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
const { | ||
Chalk | ||
} = require('./Chalk.js'); | ||
HEXTEST, | ||
Color | ||
} = require('./Color.js'); | ||
@@ -29,4 +30,3 @@ const { | ||
ALIGNMENT, | ||
FONTFACES, | ||
HEXTEST | ||
FONTFACES | ||
} = require('./constants.js'); | ||
@@ -63,3 +63,11 @@ /** | ||
pass: true | ||
}; // checking input | ||
}; | ||
const { | ||
open: red_open, | ||
close: red_close | ||
} = Color('red'); | ||
const { | ||
open: green_open, | ||
close: green_close | ||
} = Color('green'); // checking input | ||
@@ -76,3 +84,3 @@ if (INPUT === undefined || INPUT === '') { | ||
return { | ||
message: `"${Chalk.red(userFont)}" is not a valid font option.\n` + `Please use a font from the supported stack:\n${Chalk.green(Object.keys(fontfaces).map(font => fontfaces[font]).join(', '))}`, | ||
message: `"${red_open}${userFont}${red_close}" is not a valid font option.\n` + `Please use a font from the supported stack:\n${green_open}${Object.keys(fontfaces).map(font => fontfaces[font]).join(', ')}${green_close}`, | ||
pass: false | ||
@@ -87,3 +95,3 @@ }; | ||
result = { | ||
message: `"${Chalk.red(color)}" is not a valid font color option.\n` + `Please use a color from the supported stack or any valid hex color:\n${Chalk.green(`${Object.keys(colors).map(color => colors[color]).join(', ')}, candy, "#3456ff", "#f80", etc...`)}`, | ||
message: `"${red_open}${color}${red_close}" is not a valid font color option.\n` + `Please use a color from the supported stack or any valid hex color:\n` + `${green_open}${Object.keys(colors).map(color => colors[color]).join(', ')}, candy, "#3456ff", "#f80", etc...${green_close}`, | ||
pass: false | ||
@@ -94,5 +102,5 @@ }; | ||
if (Object.keys(bgcolors).indexOf(userBackground.toLowerCase()) === -1) { | ||
if (Object.keys(bgcolors).indexOf(userBackground.toLowerCase()) === -1 && !HEXTEST.test(userBackground)) { | ||
return { | ||
message: `"${Chalk.red(userBackground)}" is not a valid background option.\n` + `Please use a color from the supported stack:\n${Chalk.green(Object.keys(bgcolors).map(bgcolor => bgcolors[bgcolor]).join(', '))}`, | ||
message: `"${red_open}${userBackground}${red_close}" is not a valid background option.\n` + `Please use a color from the supported stack:\n` + `${green_open}${Object.keys(bgcolors).map(bgcolor => bgcolors[bgcolor]).join(', ')}, "#3456ff", "#f80", etc...${green_close}`, | ||
pass: false | ||
@@ -105,3 +113,3 @@ }; | ||
return { | ||
message: `"${Chalk.red(userAlign)}" is not a valid alignment option.\n` + `Please use an alignment option from the supported stack:\n${Chalk.green(alignment.join(' | '))}`, | ||
message: `"${red_open}${userAlign}${red_close}" is not a valid alignment option.\n` + `Please use an alignment option from the supported stack:\n${green_open}${alignment.join(' | ')}${green_close}`, | ||
pass: false | ||
@@ -118,3 +126,3 @@ }; | ||
return { | ||
message: `"${Chalk.red(userGradient)}" is not a valid gradient option.\n` + `Please pass in${userTransitionGradient ? ' at least' : ''} two colors.`, | ||
message: `"${red_open}${userGradient}${red_close}" is not a valid gradient option.\n` + `Please pass in${userTransitionGradient ? ' at least' : ''} two colors.`, | ||
pass: false | ||
@@ -126,3 +134,3 @@ }; | ||
return { | ||
message: `"${Chalk.red(userGradient)}" is not a valid gradient option.\n` + `Please pass in two colors.`, | ||
message: `"${red_open}${userGradient}${red_close}" is not a valid gradient option.\n` + `Please pass in two colors.`, | ||
pass: false | ||
@@ -136,3 +144,3 @@ }; | ||
result = { | ||
message: `"${Chalk.red(color)}" is not a valid gradient color option.\n` + `Please use a color from the supported stack or any valid hex color:\n${Chalk.green(`${Object.keys(gradientcolors).map(color => colors[color]).join(', ')}, "#3456ff", "#f80", etc...`)}`, | ||
message: `"${red_open}${color}${red_close}" is not a valid gradient color option.\n` + `Please use a color from the supported stack or any valid hex color:\n${green_open}${Object.keys(gradientcolors).map(color => colors[color]).join(', ')}, "#3456ff", "#f80", etc...${green_close}`, | ||
pass: false | ||
@@ -148,3 +156,3 @@ }; | ||
return { | ||
message: `"${Chalk.red(userEnv)}" is not a valid environment option.\n` + `Please use onlythe supported options:\n${Chalk.green('node | browser')}`, | ||
message: `"${red_open}${userEnv}${red_close}" is not a valid environment option.\n` + `Please use only the supported options:\n${green_open}node | browser${green_close}`, | ||
pass: false | ||
@@ -151,0 +159,0 @@ }; |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
651
lib/Color.js
@@ -7,8 +7,21 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
* @repository https://github.com/dominikwilkowski/cfonts | ||
* | ||
* Color | ||
* Abstraction for coloring hex-, keyword- and background-colors | ||
* HEXTEST - Regex to see if a string is a hex color | ||
* Rgb2hsv - Converts an RGB color value to HSV | ||
* Hsv2rgb - Converts an HSV color value to RGB | ||
* Rgb2hex - Converts RGB to HEX | ||
* Hex2rgb - Convert HEX to RGB | ||
* Hsv2hsvRad - Convert HSV coordinate to HSVrad (degree to radian) | ||
* HsvRad2hsv - Convert HSVrad color to HSV (radian to degree) | ||
* Hex2hsvRad - Convert HEX to HSVrad | ||
* HsvRad2hex - Convert HSVrad to HEX | ||
* rgb2ansi_16m - - Convert RGB values to ANSI16 million colors - truecolor | ||
* rgb2ansi256Code - Convert RGB values to ANSI256 escape code | ||
* rgb2ansi_256 - Convert RGB values to ANSI256 | ||
* ansi_2562ansi_16 - Convert ANSI256 code values to ANSI16 | ||
* get_term_color_support - Detect the ANSI support for the current terminal taking into account env vars NO_COLOR and FORCE_COLOR | ||
* Color - Abstraction for coloring hex-, keyword- and background-colors | ||
* | ||
@@ -19,21 +32,433 @@ **************************************************************************************************************************************************************/ | ||
const { | ||
UpperCaseFirst | ||
} = require('./UpperCaseFirst.js'); | ||
supportsColor | ||
} = require('supports-color'); | ||
const { | ||
Debugging | ||
} = require('./Debugging.js'); | ||
const { | ||
HEXTEST | ||
} = require('./constants.js'); | ||
const { | ||
Options | ||
} = require('./Options.js'); | ||
/** | ||
* Regex to see if a string is a hex color | ||
* | ||
* @type {RegExp} | ||
*/ | ||
const { | ||
Chalk | ||
} = require('./Chalk.js'); | ||
const HEXTEST = RegExp('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$'); | ||
/** | ||
* Converts an RGB color value to HSV | ||
* | ||
* @author https://github.com/Gavin-YYC/colorconvert | ||
* | ||
* @param {object} options - Arguments | ||
* @param {number} options.r - The red color value | ||
* @param {number} options.g - The green color value | ||
* @param {number} options.b - The blue color value | ||
* | ||
* @return {array} - The HSV representation | ||
*/ | ||
function Rgb2hsv({ | ||
r, | ||
g, | ||
b | ||
}) { | ||
r /= 255; | ||
g /= 255; | ||
b /= 255; | ||
const max = Math.max(r, g, b); | ||
const min = Math.min(r, g, b); | ||
const diff = max - min; | ||
let h = 0; | ||
let v = max; | ||
let s = max === 0 ? 0 : diff / max; // h | ||
if (max === min) { | ||
h = 0; | ||
} else if (max === r && g >= b) { | ||
h = 60 * ((g - b) / diff); | ||
} else if (max === r && g < b) { | ||
h = 60 * ((g - b) / diff) + 360; | ||
} else if (max === g) { | ||
h = 60 * ((b - r) / diff) + 120; | ||
} else { | ||
// if( max === b ) { | ||
h = 60 * ((r - g) / diff) + 240; | ||
} | ||
return [h, s * 100, v * 100]; | ||
} | ||
/** | ||
* Converts an HSV color value to RGB | ||
* | ||
* @author https://github.com/Gavin-YYC/colorconvert | ||
* | ||
* @param {number} h - The hue | ||
* @param {number} s - The saturation | ||
* @param {number} v - The value | ||
* | ||
* @typedef {object} Hsv2rgbReturnObject | ||
* @property {number} r - The red value | ||
* @property {number} g - The green value | ||
* @property {number} b - The blue value | ||
* | ||
* @return {Hsv2rgbReturnObject} - The RGB representation | ||
*/ | ||
function Hsv2rgb(h, s, v) { | ||
h /= 60; | ||
s /= 100; | ||
v /= 100; | ||
const hi = Math.floor(h) % 6; | ||
const f = h - Math.floor(h); | ||
const p = 255 * v * (1 - s); | ||
const q = 255 * v * (1 - s * f); | ||
const t = 255 * v * (1 - s * (1 - f)); | ||
v *= 255; | ||
switch (hi) { | ||
case 0: | ||
return { | ||
r: v, | ||
g: t, | ||
b: p | ||
}; | ||
case 1: | ||
return { | ||
r: q, | ||
g: v, | ||
b: p | ||
}; | ||
case 2: | ||
return { | ||
r: p, | ||
g: v, | ||
b: t | ||
}; | ||
case 3: | ||
return { | ||
r: p, | ||
g: q, | ||
b: v | ||
}; | ||
case 4: | ||
return { | ||
r: t, | ||
g: p, | ||
b: v | ||
}; | ||
case 5: | ||
return { | ||
r: v, | ||
g: p, | ||
b: q | ||
}; | ||
} | ||
} | ||
/** | ||
* Converts RGB to HEX | ||
* | ||
* @param {number} r - The Red value | ||
* @param {number} g - The Green value | ||
* @param {number} b - The Blue value | ||
* | ||
* @return {string} - A HEX color | ||
*/ | ||
function Rgb2hex(r, g, b) { | ||
const val = (b | g << 8 | r << 16 | 1 << 24).toString(16).slice(1); | ||
return '#' + val.toLowerCase(); | ||
} | ||
/** | ||
* Convert HEX to RGB | ||
* | ||
* @param {string} hex - The HEX color | ||
* | ||
* @return {array} - An object with RGB values | ||
*/ | ||
function Hex2rgb(hex) { | ||
hex = hex.replace(/^#/, ''); | ||
if (hex.length > 6) { | ||
hex = hex.slice(0, 6); | ||
} | ||
if (hex.length === 4) { | ||
hex = hex.slice(0, 3); | ||
} | ||
if (hex.length === 3) { | ||
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; | ||
} | ||
const num = parseInt(hex, 16); | ||
const r = num >> 16; | ||
const g = num >> 8 & 255; | ||
const b = num & 255; | ||
const rgb = [r, g, b]; | ||
return rgb; | ||
} | ||
/** | ||
* Convert HSV coordinate to HSVrad (degree to radian) | ||
* | ||
* @param {array} argument - The HSV representation of a color | ||
* | ||
* @return {array} - The HSVrad color | ||
*/ | ||
function Hsv2hsvRad([h, s, v]) { | ||
return [h * Math.PI / 180, s, v]; | ||
} | ||
/** | ||
* Convert HSVrad color to HSV (radian to degree) | ||
* | ||
* @param {number} hRad - H in rad | ||
* @param {number} s - S | ||
* @param {number} v - V | ||
* | ||
* @return {array} - The HSV color | ||
*/ | ||
function HsvRad2hsv(hRad, s, v) { | ||
const precision = 1000000000000; | ||
const h = Math.round(hRad * 180 / Math.PI * precision) / precision; | ||
return [h, s, v]; | ||
} | ||
/** | ||
* Convert HEX to HSVrad | ||
* | ||
* @param {string} hex - A HEX color | ||
* | ||
* @return {array} - The HSVrad color | ||
*/ | ||
function Hex2hsvRad(hex) { | ||
const [r, g, b] = Hex2rgb(hex); | ||
const hsv = Rgb2hsv({ | ||
r, | ||
g, | ||
b | ||
}); | ||
const hsvRad = Hsv2hsvRad(hsv); | ||
return hsvRad; | ||
} | ||
/** | ||
* Convert HSVrad to HEX | ||
* | ||
* @param {number} hRad - The hue in rad | ||
* @param {number} s - The saturation | ||
* @param {number} v - The value | ||
* | ||
* @return {string} - The HEX color | ||
*/ | ||
function HsvRad2hex(hRad, s, v) { | ||
const [h] = HsvRad2hsv(hRad, s, v); | ||
const { | ||
r, | ||
g, | ||
b | ||
} = Hsv2rgb(h, s, v); | ||
const hex = Rgb2hex(r, g, b); | ||
return hex; | ||
} | ||
/** | ||
* Convert RGB values to ANSI16 million colors - truecolor | ||
* | ||
* @param {number} r - Red value | ||
* @param {number} g - Green value | ||
* @param {number} b - Blue value | ||
* @param {boolean} bg - Is this a background color; default: false | ||
* | ||
* @return {string} - The opening ANSI escape sequence for the given color | ||
*/ | ||
function rgb2ansi_16m(r, g, b, bg = false) { | ||
const layer_code = bg ? 48 : 38; | ||
return `\u001b[${layer_code};2;${r};${g};${b}m`; | ||
} | ||
/** | ||
* Convert RGB values to ANSI256 escape code | ||
* | ||
* @param {number} red - Red value | ||
* @param {number} green - Green value | ||
* @param {number} blue - Blue value | ||
* | ||
* @return {number} - The ANSI escape code for the given color | ||
*/ | ||
function rgb2ansi256Code(red, green, blue) { | ||
if (red === green && green === blue) { | ||
if (red < 8) { | ||
return 16; | ||
} | ||
if (red > 248) { | ||
return 231; | ||
} | ||
return Math.round((red - 8) / 247 * 24) + 232; | ||
} | ||
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5); | ||
} | ||
/** | ||
* Convert RGB values to ANSI256 | ||
* | ||
* @param {number} r - Red value | ||
* @param {number} g - Green value | ||
* @param {number} b - Blue value | ||
* @param {boolean} bg - Is this a background color; default: false | ||
* | ||
* @return {string} - The opening ANSI escape sequence for the given color | ||
*/ | ||
function rgb2ansi_256(r, g, b, bg = false) { | ||
const layer_code = bg ? 48 : 38; | ||
const code = rgb2ansi256Code(r, g, b); | ||
return `\u001b[${layer_code};5;${code}m`; | ||
} | ||
/** | ||
* Convert ANSI256 code values to ANSI16 | ||
* | ||
* @param {number} code - The code of the ANSI256 color | ||
* @param {boolean} bg - Is this a background color; default: false | ||
* | ||
* @return {string} - The opening ANSI escape sequence for the given color | ||
*/ | ||
function ansi_2562ansi_16(code, bg = false) { | ||
let ansi_16_code; | ||
if (code <= 7) { | ||
ansi_16_code = code + 10; | ||
} | ||
if (code >= 8 && code <= 15) { | ||
ansi_16_code = code + 82; | ||
} | ||
if (code === 16) { | ||
ansi_16_code = 0; | ||
} | ||
if (code >= 17 && code <= 19) { | ||
ansi_16_code = 34; | ||
} | ||
if (code >= 20 && code <= 21 || code >= 25 && code <= 27) { | ||
ansi_16_code = 94; | ||
} | ||
if (code >= 22 && code <= 24 || code >= 58 && code <= 60 || code >= 64 && code <= 66 || code >= 94 && code <= 95 || code >= 100 && code <= 102 || code >= 106 && code <= 108 || code >= 130 && code <= 131 || code >= 136 && code <= 138 || code >= 142 && code <= 144 || code >= 148 && code <= 151 || code >= 172 && code <= 174 || code >= 178 && code <= 181 || code >= 184 && code <= 189) { | ||
ansi_16_code = 33; | ||
} | ||
if (code >= 28 && code <= 30 || code >= 34 && code <= 36 || code >= 70 && code <= 72 || code >= 76 && code <= 79 || code >= 112 && code <= 114) { | ||
ansi_16_code = 32; | ||
} | ||
if (code >= 31 && code <= 33 || code >= 37 && code <= 39 || code >= 44 && code <= 45 || code >= 61 && code <= 63 || code >= 67 && code <= 69 || code >= 73 && code <= 75 || code >= 80 && code <= 81 || code >= 103 && code <= 111 || code >= 115 && code <= 117 || code >= 152 && code <= 153) { | ||
ansi_16_code = 36; | ||
} | ||
if (code >= 40 && code <= 43 || code >= 46 && code <= 49 || code >= 82 && code <= 85 || code >= 118 && code <= 120 || code >= 154 && code <= 157) { | ||
ansi_16_code = 92; | ||
} | ||
if (code >= 50 && code <= 51 || code >= 86 && code <= 87 || code >= 121 && code <= 123 || code >= 158 && code <= 159) { | ||
ansi_16_code = 96; | ||
} | ||
if (code >= 52 && code <= 54 || code >= 88 && code <= 90 || code >= 124 && code <= 126 || code >= 166 && code <= 168) { | ||
ansi_16_code = 31; | ||
} | ||
if (code >= 55 && code <= 57 || code >= 91 && code <= 93 || code >= 96 && code <= 99 || code >= 127 && code <= 129 || code >= 132 && code <= 135 || code >= 139 && code <= 141 || code >= 145 && code <= 147 || code >= 196 && code <= 171 || code >= 175 && code <= 177) { | ||
ansi_16_code = 35; | ||
} | ||
if (code >= 160 && code <= 163 || code >= 196 && code <= 199 || code >= 202 && code <= 213) { | ||
ansi_16_code = 91; | ||
} | ||
if (code >= 164 && code <= 165 || code >= 182 && code <= 183 || code >= 200 && code <= 200 || code >= 218 && code <= 219) { | ||
ansi_16_code = 95; | ||
} | ||
if (code >= 190 && code <= 193 || code >= 214 && code <= 217 || code >= 220 && code <= 228) { | ||
ansi_16_code = 93; | ||
} | ||
if (code >= 194 && code <= 195 || code >= 229 && code <= 231 || code >= 253 && code <= 255) { | ||
ansi_16_code = 97; | ||
} | ||
if (code >= 232 && code <= 239) { | ||
ansi_16_code = 30; | ||
} | ||
if (code >= 240 && code <= 246) { | ||
ansi_16_code = 90; | ||
} | ||
if (code >= 247 && code <= 252) { | ||
ansi_16_code = 37; | ||
} | ||
if (bg) { | ||
ansi_16_code = ansi_16_code + 10; | ||
} | ||
return `\u001b[${ansi_16_code}m`; | ||
} | ||
/** | ||
* Detect the ANSI support for the current terminal taking into account env vars NO_COLOR and FORCE_COLOR | ||
* | ||
* @return {number} - 0 = no color support; 1 = 16 colors support; 2 = 256 colors support; 3 = 16 million colors support | ||
*/ | ||
function get_term_color_support() { | ||
let term_support = supportsColor().level || 3; | ||
if ('NO_COLOR' in process.env) { | ||
term_support = 0; | ||
} | ||
if (process.env['FORCE_COLOR'] === '0') { | ||
term_support = 0; | ||
} | ||
if (process.env['FORCE_COLOR'] === '1') { | ||
term_support = 1; | ||
} | ||
if (process.env['FORCE_COLOR'] === '2') { | ||
term_support = 2; | ||
} | ||
if (process.env['FORCE_COLOR'] === '3') { | ||
term_support = 3; | ||
} | ||
return term_support; | ||
} | ||
/** | ||
* Abstraction for coloring hex-, keyword- and background-colors | ||
@@ -44,7 +469,7 @@ * | ||
* | ||
* @typedef {object} ReturnObject | ||
* @typedef {object} ColorReturnObject | ||
* @property {string} open - The open ansi code | ||
* @property {string} close - The close ansi code | ||
* | ||
* @return {ReturnObject} - An object with open and close ansi codes | ||
* @return {ColorReturnObject} - An object with open and close ansi codes | ||
*/ | ||
@@ -54,4 +479,23 @@ | ||
const Color = (color, bg = false) => { | ||
// bail early if we use system color | ||
if (color === 'system' || process.env.FORCE_COLOR == '0') { | ||
const COLORS = { | ||
black: '#000', | ||
red: '#ea3223', | ||
green: '#377d22', | ||
yellow: '#fffd54', | ||
blue: '#0020f5', | ||
magenta: '#ea3df7', | ||
cyan: '#74fbfd', | ||
white: '#fff', | ||
gray: '#808080', | ||
redbright: '#ee776d', | ||
greenbright: '#8cf57b', | ||
yellowbright: '#fffb7f', | ||
bluebright: '#6974f6', | ||
magentabright: '#ee82f8', | ||
cyanbright: '#8dfafd', | ||
whitebright: '#fff' | ||
}; | ||
const support = get_term_color_support(); // bail early if we use system color | ||
if (color === 'system' || support === 0) { | ||
return { | ||
@@ -66,53 +510,124 @@ open: '', | ||
if (OPTIONS.env === 'node') { | ||
// bail if this is a chalk defined color | ||
if (color.includes('Bright')) { | ||
if (bg) { | ||
color = `bg${UpperCaseFirst(color)}`; | ||
} | ||
let open; | ||
let close = bg ? '\u001b[49m' : '\u001b[39m'; | ||
return { | ||
open: Chalk[color]._styler.open, | ||
close: Chalk[color]._styler.close | ||
}; | ||
} | ||
switch (color.toLowerCase()) { | ||
case 'transparent': | ||
open = '\u001b[49m'; | ||
break; | ||
const kind = HEXTEST.test(color) ? 'hex' : `${bg ? 'bgK' : 'k'}eyword`; | ||
let styles; | ||
case 'black': | ||
open = bg ? '\u001b[40m' : '\u001b[30m'; | ||
break; | ||
try { | ||
styles = Chalk[kind](color)._styler; | ||
} catch (error) { | ||
Debugging.error(`The color ${Chalk.yellow(color)} could not be found. Sorry about this.`); | ||
return { | ||
open: '', | ||
close: '' | ||
}; | ||
case 'red': | ||
open = bg ? '\u001b[41m' : '\u001b[31m'; | ||
break; | ||
case 'green': | ||
open = bg ? '\u001b[42m' : '\u001b[32m'; | ||
break; | ||
case 'yellow': | ||
open = bg ? '\u001b[43m' : '\u001b[33m'; | ||
break; | ||
case 'blue': | ||
open = bg ? '\u001b[44m' : '\u001b[34m'; | ||
break; | ||
case 'magenta': | ||
open = bg ? '\u001b[45m' : '\u001b[35m'; | ||
break; | ||
case 'cyan': | ||
open = bg ? '\u001b[46m' : '\u001b[36m'; | ||
break; | ||
case 'white': | ||
open = bg ? '\u001b[47m' : '\u001b[37m'; | ||
break; | ||
case 'gray': | ||
open = bg ? '\u001b[100m' : '\u001b[90m'; | ||
break; | ||
case 'redbright': | ||
open = bg ? '\u001b[101m' : '\u001b[91m'; | ||
break; | ||
case 'greenbright': | ||
open = bg ? '\u001b[102m' : '\u001b[92m'; | ||
break; | ||
case 'yellowbright': | ||
open = bg ? '\u001b[103m' : '\u001b[93m'; | ||
break; | ||
case 'bluebright': | ||
open = bg ? '\u001b[104m' : '\u001b[94m'; | ||
break; | ||
case 'magentabright': | ||
open = bg ? '\u001b[105m' : '\u001b[95m'; | ||
break; | ||
case 'cyanbright': | ||
open = bg ? '\u001b[106m' : '\u001b[96m'; | ||
break; | ||
case 'whitebright': | ||
open = bg ? '\u001b[107m' : '\u001b[97m'; | ||
break; | ||
case 'candy': | ||
open = ['\u001b[31m', '\u001b[32m', '\u001b[33m', '\u001b[35m', '\u001b[36m', '\u001b[91m', '\u001b[92m', '\u001b[93m', '\u001b[94m', '\u001b[95m', '\u001b[96m'][Math.floor(Math.random() * 11)]; | ||
break; | ||
default: | ||
{ | ||
let hex = color; | ||
if (!HEXTEST.test(color)) { | ||
return { | ||
open: '', | ||
close: '' | ||
}; | ||
} | ||
const rgb = Hex2rgb(hex); | ||
if (support === 1) { | ||
open = ansi_2562ansi_16(rgb2ansi256Code(rgb[0], rgb[1], rgb[2]), bg); | ||
} | ||
if (support === 2) { | ||
open = rgb2ansi_256(rgb[0], rgb[1], rgb[2], bg); | ||
} | ||
if (support === 3) { | ||
open = rgb2ansi_16m(rgb[0], rgb[1], rgb[2], bg); | ||
} | ||
} | ||
} | ||
return { | ||
open: styles.open, | ||
close: styles.close | ||
open, | ||
close | ||
}; | ||
} else if (!OPTIONS.env) { | ||
return { | ||
open: '', | ||
close: '' | ||
}; | ||
} else { | ||
const COLORS = { | ||
black: '#000', | ||
red: '#ea3223', | ||
green: '#377d22', | ||
yellow: '#fffd54', | ||
blue: '#0020f5', | ||
magenta: '#ea3df7', | ||
cyan: '#74fbfd', | ||
white: '#fff', | ||
gray: '#808080', | ||
redbright: '#ee776d', | ||
greenbright: '#8cf57b', | ||
yellowbright: '#fffb7f', | ||
bluebright: '#6974f6', | ||
magentabright: '#ee82f8', | ||
cyanbright: '#8dfafd', | ||
whitebright: '#fff' | ||
}; | ||
if (!HEXTEST.test(color)) { | ||
color = COLORS[color.toLowerCase()]; | ||
if (!color) { | ||
return { | ||
open: '', | ||
close: '' | ||
}; | ||
} | ||
} | ||
@@ -135,3 +650,17 @@ | ||
module.exports = exports = { | ||
HEXTEST, | ||
Rgb2hsv, | ||
Hsv2rgb, | ||
Rgb2hex, | ||
Hex2rgb, | ||
Hsv2hsvRad, | ||
HsvRad2hsv, | ||
Hex2hsvRad, | ||
HsvRad2hex, | ||
rgb2ansi_16m, | ||
rgb2ansi256Code, | ||
rgb2ansi_256, | ||
ansi_2562ansi_16, | ||
get_term_color_support, | ||
Color | ||
}; |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -38,4 +38,2 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
Debugging.report(`Running Colorize`, 1); | ||
let candyColors = [// allowed candy colors | ||
'red', 'green', 'yellow', 'magenta', 'cyan', 'redBright', 'greenBright', 'yellowBright', 'blueBright', 'magentaBright', 'cyanBright']; | ||
@@ -46,3 +44,3 @@ if (character !== undefined) { | ||
for (let i = 0; i < fontColors; i++) { | ||
const color = optionColors[i] === 'candy' ? candyColors[Math.floor(Math.random() * candyColors.length)] : optionColors[i] || 'system'; | ||
const color = optionColors[i] || 'system'; | ||
const { | ||
@@ -61,3 +59,3 @@ open: openNew, | ||
if (fontColors === 1) { | ||
const color = optionColors[0] === 'candy' ? candyColors[Math.floor(Math.random() * candyColors.length)] : optionColors[0] || 'system'; | ||
const color = optionColors[0] || 'system'; | ||
const { | ||
@@ -64,0 +62,0 @@ open: openNew, |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -21,13 +21,7 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
* PACKAGE | ||
* HEXTEST | ||
* | ||
**************************************************************************************************************************************************************/ | ||
'use strict'; | ||
'use strict'; // global defaults | ||
const { | ||
Chalk | ||
} = require('./Chalk.js'); // global defaults | ||
const CHARS = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "|", "!", "?", ".", "+", "-", "_", "=", "@", "#", "$", "%", "&", "(", ")", "/", ":", ";", ",", " ", "'", "\""]; | ||
const CHARS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '|', '!', '?', '.', '+', '-', '_', '=', '@', '#', '$', '%', '&', '(', ')', '/', ':', ';', ',', ' ', "'", '"']; | ||
const COLORS = { | ||
@@ -130,3 +124,3 @@ system: 'system', | ||
description: 'Use to define the font face', | ||
example: `--font block ${Chalk.green(`( ${Object.keys(FONTFACES).map(font => FONTFACES[font]).join(', ')} )`)}`, | ||
example: `--font block [green-open][ ${Object.keys(FONTFACES).map(font => FONTFACES[font]).join(', ')} ][green-close]`, | ||
short: '-f', | ||
@@ -138,3 +132,3 @@ options: Object.keys(FONTFACES).map(color => FONTFACES[color]), | ||
description: 'Use to define the font color', | ||
example: `--colors red ${Chalk.green(`( ${Object.keys(COLORS).map(color => COLORS[color]).join(', ')}, #ff8800, hex-colors etc... )`)}`, | ||
example: `--colors red [green-open][ ${Object.keys(COLORS).map(color => COLORS[color]).join(', ')}, #ff8800, hex-colors etc... ][green-close]`, | ||
short: '-c', | ||
@@ -146,3 +140,3 @@ options: true, | ||
description: 'Use to define background color', | ||
example: `--background blue ${Chalk.green(`( ${Object.keys(BGCOLORS).map(bgcolor => BGCOLORS[bgcolor]).join(', ')} )`)}`, | ||
example: `--background blue [green-open][ ${Object.keys(BGCOLORS).map(bgcolor => BGCOLORS[bgcolor]).join(', ')} ][green-close]`, | ||
short: '-b', | ||
@@ -154,3 +148,3 @@ options: Object.keys(BGCOLORS).map(color => BGCOLORS[color]), | ||
description: 'Use to align your text output', | ||
example: `--align ${Chalk.green(`( ${ALIGNMENT.join(', ')} )`)}`, | ||
example: `--align [green-open][ ${ALIGNMENT.join(', ')} ][green-close]`, | ||
short: '-a', | ||
@@ -189,3 +183,3 @@ options: ALIGNMENT, | ||
description: 'Use to define a start and end color of a gradient', | ||
example: '--gradient red,blue', | ||
example: '--gradient red,blue,green', | ||
short: '-g', | ||
@@ -209,3 +203,3 @@ options: true, | ||
description: 'Use to define what environment you run CFonts in.', | ||
example: `--env ${Chalk.green('"node", "browser"')}`, | ||
example: `--env [green-open][ "node", "browser" ][green-close]`, | ||
short: '-e', | ||
@@ -232,3 +226,2 @@ options: true, | ||
const HEXTEST = RegExp('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$'); | ||
module.exports = exports = { | ||
@@ -243,4 +236,3 @@ CHARS, | ||
CLIOPTIONS, | ||
PACKAGE, | ||
HEXTEST | ||
PACKAGE | ||
}; |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -19,4 +19,4 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
const { | ||
Chalk | ||
} = require('./Chalk.js'); | ||
Color | ||
} = require('./Color.js'); | ||
/** | ||
@@ -69,3 +69,7 @@ * DEBUG object for tracking debug mode and level | ||
if (debug && level >= debuglevel) { | ||
console.log(Chalk.bgWhite(`\n${Chalk.bold(' \u2611 ')} ${text}`)); | ||
const { | ||
open, | ||
close | ||
} = Color('black', true); | ||
console.log(`${open}\n\u001b[1m \u2611 \u001b[22m ${text}${close}`); | ||
} | ||
@@ -84,3 +88,15 @@ }, | ||
if (debug && level >= debuglevel) { | ||
console.log(Chalk.bgWhite(`\n${Chalk.bold.green(' \u2611 ')} ${Chalk.black(`${text} `)}`)); | ||
const { | ||
open: blackbg_open, | ||
close: blackbg_close | ||
} = Color('black', true); | ||
const { | ||
open: green_open, | ||
close: green_close | ||
} = Color('green'); | ||
const { | ||
open: white_open, | ||
close: white_close | ||
} = Color('white'); | ||
console.log(`${blackbg_open}\n\u001b[1m${green_open} \u2611 ${green_close}\u001b[22m ${white_open}${text}${white_close}${blackbg_close}`); | ||
} | ||
@@ -99,3 +115,15 @@ }, | ||
if (debug && level >= debuglevel) { | ||
console.error(Chalk.bgWhite(`\n${Chalk.red(' \u2612 ')} ${Chalk.black(`${text} `)}`)); | ||
const { | ||
open: blackbg_open, | ||
close: blackbg_close | ||
} = Color('black', true); | ||
const { | ||
open: red_open, | ||
close: red_close | ||
} = Color('red'); | ||
const { | ||
open: white_open, | ||
close: white_close | ||
} = Color('white'); | ||
console.error(`${blackbg_open}\n${red_open} \u2612 ${red_close} ${white_open}${text}${white_close}${blackbg_close}`); | ||
} | ||
@@ -102,0 +130,0 @@ } |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -27,4 +27,4 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
const { | ||
Chalk | ||
} = require('./Chalk.js'); | ||
Color | ||
} = require('./Color.js'); | ||
/** | ||
@@ -42,7 +42,11 @@ * Display the help generated from our CLIOPTIONS | ||
}); | ||
console.log(` ${headline}` + `This is a tool for sexy fonts in the console. Give your cli some love.\n\n` + `Usage: cfonts "<value>" [option1] <input1> [option2] <input1>,<input2> [option3]\n` + `Example: ${Chalk.bold('$ cfonts "sexy font" -f chrome -a center -c red,green,gray')}\n\n` + `Options:\n`); | ||
console.log(` ${headline}` + `This is a tool for sexy fonts in the console. Give your cli some love.\n\n` + `Usage: cfonts "<value>" [option1] <input1> [option2] <input1>,<input2> [option3]\n` + `Example: \u001b[1m$ cfonts "sexy font" -f chrome -a center -c red,green,gray\u001b[22m\n\n` + `Options:\n`); | ||
const { | ||
open, | ||
close | ||
} = Color('green'); | ||
Object.keys(CLIOPTIONS).forEach(option => { | ||
console.log(Chalk.bold(`${option}, ${CLIOPTIONS[option].short}`)); | ||
console.log(`\u001b[1m${option}, ${CLIOPTIONS[option].short}\u001b[22m`); | ||
console.log(CLIOPTIONS[option].description); | ||
console.log(`${Chalk.bold('$')} cfonts ${CLIOPTIONS[option].example}\n`); | ||
console.log(`\u001b[1m$\u001b[22m cfonts ${CLIOPTIONS[option].example.replace(/\[green-open\]/g, open).replace(/\[green-close\]/g, close)}\n`); | ||
}); | ||
@@ -49,0 +53,0 @@ }; |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -18,2 +18,4 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
const path = require('path'); | ||
const { | ||
@@ -35,3 +37,3 @@ Debugging | ||
try { | ||
let FONTFACE = require(`../fonts/${font}.json`); // read font file | ||
let FONTFACE = require(path.normalize(`../fonts/${font}.json`)); // read font file | ||
@@ -38,0 +40,0 @@ |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
@@ -7,14 +7,6 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
* @repository https://github.com/dominikwilkowski/cfonts | ||
* | ||
* Rgb2hsv - Converts an RGB color value to HSV | ||
* Hsv2rgb - Converts an HSV color value to RGB | ||
* Rgb2hex - Converts RGB to HEX | ||
* Hex2rgb - Convert HEX to RGB | ||
* Hsv2hsvRad - Convert HSV coordinate to HSVrad (degree to radian) | ||
* HsvRad2hsv - Convert HSVrad color to HSV (radian to degree) | ||
* Hex2hsvRad - Convert HEX to HSVrad | ||
* HsvRad2hex - Convert HSVrad to HEX | ||
* GetLinear - Interpolate a linear path from a number to another number | ||
@@ -38,2 +30,10 @@ * GetTheta - Interpolate a radial path from a number to another number | ||
const { | ||
Color, | ||
Hex2rgb, | ||
Hex2hsvRad, | ||
HsvRad2hex, | ||
Rgb2hex | ||
} = require('./Color.js'); | ||
const { | ||
GetLongestLine | ||
@@ -49,236 +49,3 @@ } = require('./GetLongestLine.js'); | ||
} = require('./Debugging.js'); | ||
const { | ||
Color | ||
} = require('./Color.js'); | ||
/** | ||
* Converts an RGB color value to HSV | ||
* | ||
* @author https://github.com/Gavin-YYC/colorconvert | ||
* | ||
* @param {object} options - Arguments | ||
* @param {number} options.r - The red color value | ||
* @param {number} options.g - The green color value | ||
* @param {number} options.b - The blue color value | ||
* | ||
* @return {array} - The HSV representation | ||
*/ | ||
function Rgb2hsv({ | ||
r, | ||
g, | ||
b | ||
}) { | ||
r /= 255; | ||
g /= 255; | ||
b /= 255; | ||
const max = Math.max(r, g, b); | ||
const min = Math.min(r, g, b); | ||
const diff = max - min; | ||
let h = 0; | ||
let v = max; | ||
let s = max === 0 ? 0 : diff / max; // h | ||
if (max === min) { | ||
h = 0; | ||
} else if (max === r && g >= b) { | ||
h = 60 * ((g - b) / diff); | ||
} else if (max === r && g < b) { | ||
h = 60 * ((g - b) / diff) + 360; | ||
} else if (max === g) { | ||
h = 60 * ((b - r) / diff) + 120; | ||
} else { | ||
// if( max === b ) { | ||
h = 60 * ((r - g) / diff) + 240; | ||
} | ||
return [h, s * 100, v * 100]; | ||
} | ||
/** | ||
* Converts an HSV color value to RGB | ||
* | ||
* @author https://github.com/Gavin-YYC/colorconvert | ||
* | ||
* @param {number} h - The hue | ||
* @param {number} s - The saturation | ||
* @param {number} v - The value | ||
* | ||
* @typedef {object} ReturnObject | ||
* @property {number} r - The red value | ||
* @property {number} g - The green value | ||
* @property {number} b - The blue value | ||
* | ||
* @return {ReturnObject} - The RGB representation | ||
*/ | ||
function Hsv2rgb(h, s, v) { | ||
h /= 60; | ||
s /= 100; | ||
v /= 100; | ||
const hi = Math.floor(h) % 6; | ||
const f = h - Math.floor(h); | ||
const p = 255 * v * (1 - s); | ||
const q = 255 * v * (1 - s * f); | ||
const t = 255 * v * (1 - s * (1 - f)); | ||
v *= 255; | ||
switch (hi) { | ||
case 0: | ||
return { | ||
r: v, | ||
g: t, | ||
b: p | ||
}; | ||
case 1: | ||
return { | ||
r: q, | ||
g: v, | ||
b: p | ||
}; | ||
case 2: | ||
return { | ||
r: p, | ||
g: v, | ||
b: t | ||
}; | ||
case 3: | ||
return { | ||
r: p, | ||
g: q, | ||
b: v | ||
}; | ||
case 4: | ||
return { | ||
r: t, | ||
g: p, | ||
b: v | ||
}; | ||
case 5: | ||
return { | ||
r: v, | ||
g: p, | ||
b: q | ||
}; | ||
} | ||
} | ||
/** | ||
* Converts RGB to HEX | ||
* | ||
* @param {number} r - The Red value | ||
* @param {number} g - The Green value | ||
* @param {number} b - The Blue value | ||
* | ||
* @return {string} - A HEX color | ||
*/ | ||
function Rgb2hex(r, g, b) { | ||
const val = (b | g << 8 | r << 16 | 1 << 24).toString(16).slice(1); | ||
return '#' + val.toLowerCase(); | ||
} | ||
/** | ||
* Convert HEX to RGB | ||
* | ||
* @param {string} hex - The HEX color | ||
* | ||
* @return {array} - An object with RGB values | ||
*/ | ||
function Hex2rgb(hex) { | ||
hex = hex.replace(/^#/, ''); | ||
if (hex.length > 6) { | ||
hex = hex.slice(0, 6); | ||
} | ||
if (hex.length === 4) { | ||
hex = hex.slice(0, 3); | ||
} | ||
if (hex.length === 3) { | ||
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; | ||
} | ||
const num = parseInt(hex, 16); | ||
const r = num >> 16; | ||
const g = num >> 8 & 255; | ||
const b = num & 255; | ||
const rgb = [r, g, b]; | ||
return rgb; | ||
} | ||
/** | ||
* Convert HSV coordinate to HSVrad (degree to radian) | ||
* | ||
* @param {array} argument - The HSV representation of a color | ||
* | ||
* @return {array} - The HSVrad color | ||
*/ | ||
function Hsv2hsvRad([h, s, v]) { | ||
return [h * Math.PI / 180, s, v]; | ||
} | ||
/** | ||
* Convert HSVrad color to HSV (radian to degree) | ||
* | ||
* @param {number} hRad - H in rad | ||
* @param {number} s - S | ||
* @param {number} v - V | ||
* | ||
* @return {array} - The HSV color | ||
*/ | ||
function HsvRad2hsv(hRad, s, v) { | ||
return [hRad * 180 / Math.PI, s, v]; | ||
} | ||
/** | ||
* Convert HEX to HSVrad | ||
* | ||
* @param {string} hex - A HEX color | ||
* | ||
* @return {array} - The HSVrad color | ||
*/ | ||
function Hex2hsvRad(hex) { | ||
const [r, g, b] = Hex2rgb(hex); | ||
const hsv = Rgb2hsv({ | ||
r, | ||
g, | ||
b | ||
}); | ||
const hsvRad = Hsv2hsvRad(hsv); | ||
return hsvRad; | ||
} | ||
/** | ||
* Convert HSVrad to HEX | ||
* | ||
* @param {number} hRad - The hue in rad | ||
* @param {number} s - The saturation | ||
* @param {number} v - The value | ||
* | ||
* @return {string} - The HEX color | ||
*/ | ||
function HsvRad2hex(hRad, s, v) { | ||
const [h] = HsvRad2hsv(hRad, s, v); | ||
const { | ||
r, | ||
g, | ||
b | ||
} = Hsv2rgb(h, s, v); | ||
const hex = Rgb2hex(r, g, b); | ||
return hex; | ||
} | ||
/** | ||
* Interpolate a linear path from a number to another number | ||
@@ -548,10 +315,5 @@ * | ||
let firstCharacterPosition; | ||
let longestLine; | ||
let firstCharacterPosition = GetFirstCharacterPosition(output); | ||
let longestLine = GetLongestLine(output).length; | ||
if (!independentGradient) { | ||
firstCharacterPosition = GetFirstCharacterPosition(output); | ||
longestLine = GetLongestLine(output).length; | ||
} | ||
for (let i = 0; i < lines; i++) { | ||
@@ -578,10 +340,2 @@ const start = i * (fontLines + lineHeight); | ||
module.exports = exports = { | ||
Rgb2hsv, | ||
Hsv2rgb, | ||
Rgb2hex, | ||
Hex2rgb, | ||
Hsv2hsvRad, | ||
HsvRad2hsv, | ||
Hex2hsvRad, | ||
HsvRad2hex, | ||
GetLinear, | ||
@@ -588,0 +342,0 @@ GetTheta, |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -43,4 +43,4 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
const { | ||
Chalk | ||
} = require('./Chalk.js'); | ||
Color | ||
} = require('./Color.js'); | ||
@@ -77,3 +77,7 @@ const { | ||
if (!args.text) { | ||
Log.error(`Please provide text to convert with ${Chalk.green(`cfonts "Text"`)}\n` + `Run ${Chalk.green(`cfonts --help`)} for more infos`); | ||
const { | ||
open: green_open, | ||
close: green_close | ||
} = Color('green'); | ||
Log.error(`Please provide text to convert with ${green_open}cfonts "Text"${green_close}\n` + `Run ${green_open}cfonts --help${green_close} for more infos`); | ||
return; | ||
@@ -80,0 +84,0 @@ } |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -19,4 +19,4 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
const { | ||
Chalk | ||
} = require('./Chalk.js'); | ||
Color | ||
} = require('./Color.js'); | ||
/** | ||
@@ -38,3 +38,7 @@ * Logging prettiness | ||
console.error(`\n ${Chalk.bold.red('Ouch:')} ${text}\n`); | ||
const { | ||
open, | ||
close | ||
} = Color('red'); | ||
console.error(`\n \u001b[1m${open}Ouch:${close}\u001b[22m ${text}\n`); | ||
} | ||
@@ -41,0 +45,0 @@ }; |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -68,3 +68,3 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
* @param {array} options.colors - Colors for font, Default: [] | ||
* @param {string} options.background - Chalk color string for background, Default 'Black' | ||
* @param {string} options.background - Color string for background, Default 'Black' | ||
* @param {string} options.backgroundColor - Alias for background | ||
@@ -71,0 +71,0 @@ * @param {number} options.letterSpacing - Space between letters, Default: set by selected font face |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -23,6 +23,2 @@ * @repository https://github.com/dominikwilkowski/cfonts | ||
const { | ||
RenderConsole | ||
} = require('./RenderConsole.js'); | ||
const { | ||
Debugging, | ||
@@ -148,105 +144,87 @@ DEBUG | ||
if (OPTIONS.font === 'console') { | ||
// console fontface is pretty easy to process | ||
FONTFACE = { | ||
colors: 1, | ||
lines: 1 | ||
}; | ||
const consoleOutput = RenderConsole(INPUT, OPTIONS, size); | ||
output = consoleOutput.output; | ||
lines = consoleOutput.lines; | ||
} else { | ||
// all other fontfaces need the font-file and some more work | ||
FONTFACE = GetFont(OPTIONS.font); | ||
FONTFACE = GetFont(OPTIONS.font); | ||
if (!FONTFACE) { | ||
Log.error(`Font file for the font "${OPTIONS.font}" could not be found.\nTry reinstalling this package.`); | ||
return false; | ||
} // setting the letterspacing preference from font face if there is no user overwrite | ||
if (!FONTFACE) { | ||
Log.error(`Font file for the font "${OPTIONS.font}" could not be found.\nTry reinstalling this package.`); | ||
return false; | ||
} // setting the letterspacing preference from font face if there is no user overwrite | ||
if (SETTINGS.letterSpacing === undefined) { | ||
Debugging.report(`Looking up letter spacing from font face`, 1); | ||
let width = 0; | ||
FONTFACE.letterspace.forEach(item => { | ||
let char = item.replace(/(<([^>]+)>)/ig, ''); // get character and strip color infos | ||
if (SETTINGS.letterSpacing === undefined) { | ||
Debugging.report(`Looking up letter spacing from font face`, 1); | ||
let width = 0; | ||
FONTFACE.letterspace.forEach(item => { | ||
let char = item.replace(/(<([^>]+)>)/gi, ''); // get character and strip color infos | ||
if (width < char.length) { | ||
width = char.length; | ||
} | ||
}); | ||
Debugging.report(`Letter spacing set to font face default: "${width}"`, 2); | ||
OPTIONS.letterSpacing = width; | ||
} | ||
if (width < char.length) { | ||
width = char.length; | ||
} | ||
}); | ||
Debugging.report(`Letter spacing set to font face default: "${width}"`, 2); | ||
OPTIONS.letterSpacing = width; | ||
} | ||
let lineLength = CharLength(FONTFACE.buffer, FONTFACE.lines, OPTIONS); // count each output character per line and start with the buffer | ||
let lineLength = CharLength(FONTFACE.buffer, FONTFACE.lines, OPTIONS); // count each output character per line and start with the buffer | ||
let maxChars = 0; // count each character we print for maxLength option | ||
let maxChars = 0; // count each character we print for maxLength option | ||
output = AddLine([], FONTFACE.lines, FONTFACE.buffer, OPTIONS.lineHeight); // create first lines with buffer | ||
output = AddLine([], FONTFACE.lines, FONTFACE.buffer, OPTIONS.lineHeight); // create first lines with buffer | ||
lines++; | ||
output = AddLetterSpacing(output, FONTFACE.lines, FONTFACE.letterspace, FONTFACE.colors, OPTIONS.colors, OPTIONS.letterSpacing); // add letter spacing to the beginning | ||
lines++; | ||
lineLength += CharLength(FONTFACE.letterspace, FONTFACE.lines, OPTIONS) * OPTIONS.letterSpacing; // count the space for the letter spacing | ||
for (let i = 0; i < INPUT.length; i++) { | ||
// iterate through the message | ||
let CHAR = INPUT.charAt(i).toUpperCase(); // the current character we convert, only upper case is supported at this time | ||
for (let i = 0; i < INPUT.length; i++) { | ||
// iterate through the message | ||
let CHAR = INPUT.charAt(i).toUpperCase(); // the current character we convert, only upper case is supported at this time | ||
let lastLineLength = lineLength; // we need the lineLength for alignment before we look up if the next char fits | ||
let lastLineLength = lineLength; // we need the lineLength for alignment before we look up if the next char fits | ||
Debugging.report(`Character found in font: "${CHAR}"`, 2); | ||
Debugging.report(`Character found in font: "${CHAR}"`, 2); | ||
if (CHAR !== `|`) { | ||
// what will the line length be if we add the next char? | ||
lineLength += CharLength(FONTFACE.chars[CHAR], FONTFACE.lines, OPTIONS); // get the length of this character | ||
if (CHAR !== `|`) { | ||
// what will the line length be if we add the next char? | ||
lineLength += CharLength(FONTFACE.chars[CHAR], FONTFACE.lines, OPTIONS); // get the length of this character | ||
lineLength += CharLength(FONTFACE.letterspace, FONTFACE.lines, OPTIONS) * OPTIONS.letterSpacing; // new line, new line length | ||
} // jump to next line after OPTIONS.maxLength characters or when line break is found or the console windows would have ran out of space | ||
lineLength += CharLength(FONTFACE.letterspace, FONTFACE.lines, OPTIONS) * OPTIONS.letterSpacing; // new line, new line length | ||
} // jump to next line after OPTIONS.maxLength characters or when line break is found or the console windows would have ran out of space | ||
if (maxChars >= OPTIONS.maxLength && OPTIONS.maxLength != 0 || CHAR === `|` || lineLength > size.width) { | ||
lines++; | ||
Debugging.report(`NEWLINE: maxChars: ${maxChars}, ` + `OPTIONS.maxLength: ${OPTIONS.maxLength}, ` + `CHAR: ${CHAR}, ` + `lineLength: ${lineLength}, ` + `Size.width: ${size.width} `, 2); | ||
if (maxChars >= OPTIONS.maxLength && OPTIONS.maxLength != 0 || CHAR === `|` || lineLength > size.width) { | ||
lines++; | ||
Debugging.report(`NEWLINE: maxChars: ${maxChars}, ` + `OPTIONS.maxLength: ${OPTIONS.maxLength}, ` + `CHAR: ${CHAR}, ` + `lineLength: ${lineLength}, ` + `Size.width: ${size.width} `, 2); | ||
if (OPTIONS.env === 'node') { | ||
output = AlignText(output, lastLineLength, FONTFACE.lines, OPTIONS.align, size); // calculate alignment based on lineLength | ||
} | ||
if (OPTIONS.env === 'node') { | ||
output = AlignText(output, lastLineLength, FONTFACE.lines, OPTIONS.align, size); // calculate alignment based on lineLength | ||
} | ||
lineLength += CharLength(FONTFACE.letterspace, FONTFACE.lines, OPTIONS) * OPTIONS.letterSpacing; // each new line starts with letter spacing | ||
lineLength = CharLength(FONTFACE.buffer, FONTFACE.lines, OPTIONS); // new line: new line length | ||
lineLength = CharLength(FONTFACE.buffer, FONTFACE.lines, OPTIONS); // new line: new line length | ||
lineLength += CharLength(FONTFACE.letterspace, FONTFACE.lines, OPTIONS) * OPTIONS.letterSpacing; // each new line starts with letter spacing | ||
if (CHAR !== `|`) { | ||
// if this is a character and not a line break | ||
lineLength += CharLength(FONTFACE.letterspace, FONTFACE.lines, OPTIONS) * OPTIONS.letterSpacing; // add letter spacing at the end | ||
if (CHAR !== `|`) { | ||
// if this is a character and not a line break | ||
lineLength += CharLength(FONTFACE.chars[CHAR], FONTFACE.lines, OPTIONS); // get the length of this character | ||
lineLength += CharLength(FONTFACE.letterspace, FONTFACE.lines, OPTIONS) * OPTIONS.letterSpacing; // add letter spacing at the end | ||
} | ||
maxChars = 0; // new line, new maxLength goal | ||
output = AddLine(output, FONTFACE.lines, FONTFACE.buffer, OPTIONS.lineHeight); // adding new line | ||
// add letter spacing to the beginning | ||
output = AddLetterSpacing(output, FONTFACE.lines, FONTFACE.letterspace, FONTFACE.colors, OPTIONS.colors, OPTIONS.letterSpacing); | ||
lineLength += CharLength(FONTFACE.chars[CHAR], FONTFACE.lines, OPTIONS); // get the length of this character | ||
} | ||
Debugging.report(`lineLength at: "${lineLength}"`, 2); | ||
maxChars = 0; // new line, new maxLength goal | ||
if (CHAR !== `|`) { | ||
maxChars++; // counting all printed characters | ||
output = AddLine(output, FONTFACE.lines, FONTFACE.buffer, OPTIONS.lineHeight); // adding new line | ||
// add letter spacing to the beginning | ||
} | ||
output = AddChar(CHAR, output, FONTFACE.lines, FONTFACE.chars, FONTFACE.colors, OPTIONS.colors); // add new character | ||
Debugging.report(`lineLength at: "${lineLength}"`, 2); | ||
output = AddLetterSpacing(output, FONTFACE.lines, FONTFACE.letterspace, FONTFACE.colors, OPTIONS.colors, OPTIONS.letterSpacing); | ||
} | ||
} | ||
if (CHAR !== `|`) { | ||
maxChars++; // counting all printed characters | ||
if (OPTIONS.env === 'node') { | ||
output = AlignText(output, lineLength, FONTFACE.lines, OPTIONS.align, size); // alignment last line | ||
output = AddLetterSpacing(output, FONTFACE.lines, FONTFACE.letterspace, FONTFACE.colors, OPTIONS.colors, OPTIONS.letterSpacing); | ||
output = AddChar(CHAR, output, FONTFACE.lines, FONTFACE.chars, FONTFACE.colors, OPTIONS.colors); // add new character | ||
} | ||
} | ||
if (OPTIONS.env === 'node') { | ||
output = AlignText(output, lineLength, FONTFACE.lines, OPTIONS.align, size); // alignment last line | ||
} | ||
if (OPTIONS.gradient) { | ||
@@ -285,3 +263,3 @@ output = PaintGradient({ | ||
let write = output.join(OPTIONS.env === 'node' ? `\n` : '<br>'); | ||
let write = output.join(OPTIONS.env === 'node' ? `\n` : '<br>\n'); | ||
@@ -288,0 +266,0 @@ if (OPTIONS.env === 'browser') { |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
@@ -7,3 +7,3 @@ /*************************************************************************************************************************************************************** | ||
* | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2 | ||
* @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv3 | ||
* @author Dominik Wilkowski hi@dominik-wilkowski.com | ||
@@ -10,0 +10,0 @@ * @repository https://github.com/dominikwilkowski/cfonts |
{ | ||
"name": "cfonts", | ||
"description": "Sexy fonts for the console", | ||
"version": "2.10.1", | ||
"version": "3.0.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -23,8 +23,2 @@ "author": { | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "GPL-2.0", | ||
"url": "https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE" | ||
} | ||
], | ||
"engines": { | ||
@@ -34,4 +28,3 @@ "node": ">=10" | ||
"scripts": { | ||
"prepublish": "yarn build && yarn test", | ||
"test": "yarn build && yarn test:unit && yarn test:lint && yarn test:types && yarn test:fonts", | ||
"test": "yarn format && yarn build && yarn test:unit && yarn test:lint && yarn test:types && yarn test:fonts", | ||
"test:fonts": "node ./test/fonttest.js", | ||
@@ -42,6 +35,9 @@ "test:watch": "jest --watchAll --coverage", | ||
"test:lint": "eslint src/", | ||
"build": "yarn build:lib && yarn build:bin", | ||
"test:format": "prettier --list-different \"**/*.{js,json}\"", | ||
"format": "prettier --write \"**/*.{js,json}\"", | ||
"build": "yarn build:lib && yarn build:bin && yarn build:fonts", | ||
"build:bin": "npx mkdirp bin && mv lib/bin.js bin/index.js", | ||
"build:lib": "npx mkdirp lib && babel src --out-dir lib", | ||
"types:clean": "find lib/ -type f -name '*.d.ts' -exec rm {} +", | ||
"build:fonts": "npx mkdirp fonts && npx cpy-cli \"../fonts/*\" \"./fonts/\"", | ||
"types:clean": "npx trash-cli \"lib/*.d.ts\"", | ||
"watch": "yarn build:lib && onchange 'src/**/*' -- yarn build:lib", | ||
@@ -60,2 +56,3 @@ "coveralls": "jest --coverage --coverageReporters=text-lcov | coveralls", | ||
"onchange": "^7.1.0", | ||
"prettier": "^2.6.2", | ||
"typescript": "^4.6.3" | ||
@@ -65,3 +62,3 @@ }, | ||
"dependencies": { | ||
"chalk": "^4", | ||
"supports-color": "^8", | ||
"window-size": "^1.1.1" | ||
@@ -134,3 +131,9 @@ }, | ||
}, | ||
"license": "GPL-2.0" | ||
"licenses": [ | ||
{ | ||
"type": "GPL-3.0", | ||
"url": "https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE" | ||
} | ||
], | ||
"license": "GPL-3.0" | ||
} |
497
README.md
@@ -1,18 +0,17 @@ | ||
```shell | ||
```sh | ||
██████╗ ███████╗ ██████╗ ███╗ ██╗ ████████╗ ███████╗ | ||
██╔════╝ ██╔════╝ ██╔═══██╗ ████╗ ██║ ╚══██╔══╝ ██╔════╝ | ||
██║ █████╗ ██║ ██║ ██╔██╗ ██║ ██║ ███████╗ | ||
██║ ██╔══╝ ██║ ██║ ██║╚██╗██║ ██║ ╚════██║ | ||
╚██████╗ ██║ ╚██████╔╝ ██║ ╚████║ ██║ ███████║ | ||
╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ | ||
██║ ██╔══╝ ██║ ██║ ██║╚██╗██║ ██║ ╚════██║ ╔╗╔ ╔═╗ ╔╦╗ ╔═╗ ╦ ╔═╗ | ||
╚██████╗ ██║ ╚██████╔╝ ██║ ╚████║ ██║ ███████║ ║║║ ║ ║ ║║ ║╣ ║ ╚═╗ | ||
╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝ ╝╚╝ ╚═╝ ═╩╝ ╚═╝ ╚╝ ╚═╝ | ||
``` | ||
![cfont styles](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/example1.png) | ||
![cfont styles](./img/example1.png) | ||
<p align="center"><img src="https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/example2.png" alt="api example"></p> | ||
<p align="center"><a href="https://nodei.co/npm/cfonts/"><img src="https://nodei.co/npm/cfonts.png?downloads=true" alt="npm status"></a></p> | ||
<p align="center"><img src="./img/example2.png" alt="api example"></p> | ||
<p align="center"> | ||
<a href="https://travis-ci.org/dominikwilkowski/cfonts"><img src="https://travis-ci.org/dominikwilkowski/cfonts.svg?branch=released" alt="build status"></a> | ||
<a href='https://coveralls.io/github/dominikwilkowski/cfonts?branch=released'><img src='https://coveralls.io/repos/github/dominikwilkowski/cfonts/badge.svg?branch=released' alt='CFont Coverage Status' /></a> | ||
<a href="https://github.com/dominikwilkowski/cfonts/actions/workflows/testing.yml"><img src="https://github.com/dominikwilkowski/cfonts/actions/workflows/testing.yml/badge.svg" alt="build status"></a> | ||
<a href="https://www.npmjs.com/package/cfonts"><img alt="npm" src="https://img.shields.io/npm/v/cfonts"></a> | ||
<a href='https://coveralls.io/github/dominikwilkowski/cfonts?branch=released'><img src='https://coveralls.io/repos/github/dominikwilkowski/cfonts/badge.svg?branch=released' alt='cfonts Coverage Status' /></a> | ||
</p> | ||
@@ -24,15 +23,21 @@ | ||
To install the CLI app, simply NPM install it globally. | ||
### [npm](https://www.npmjs.com/package/cfonts) | ||
```shell | ||
$ npm install cfonts -g | ||
```sh | ||
npm i cfonts -g | ||
``` | ||
### [yarn](https://yarnpkg.com/package/cfonts) | ||
```sh | ||
yarn global add cfonts | ||
``` | ||
To use it in your shell: | ||
```shell | ||
```sh | ||
$ cfonts "Hello|World\!" | ||
``` | ||
_Remember to escape the `!` character with `\` in the shell_ | ||
_💡 Remember to escape the `!` character with `\` in the shell_ | ||
@@ -42,5 +47,5 @@ Or use it in your project: | ||
```js | ||
const CFonts = require('cfonts'); | ||
const cfonts = require('cfonts'); | ||
CFonts.say('Hello|world!', { | ||
cfonts.say('Hello|world!', { | ||
font: 'block', // define the font face | ||
@@ -57,3 +62,3 @@ align: 'left', // define text alignment | ||
transitionGradient: false, // define if this is a transition between colors directly | ||
env: 'node' // define the environment CFonts is being executed in | ||
env: 'node' // define the environment cfonts is being executed in | ||
}); | ||
@@ -64,8 +69,8 @@ ``` | ||
You can use CFonts in your project without the direct output to the console: | ||
You can use `cfonts` in your project without the direct output to the console: | ||
```js | ||
const CFonts = require('cfonts'); | ||
const cfonts = require('cfonts'); | ||
const prettyFont = CFonts.render('Hello|world!', {/* same settings object as above */}); | ||
const prettyFont = cfonts.render('Hello|world!', {/* same settings object as above */}); | ||
@@ -79,406 +84,29 @@ prettyFont.string // the ansi string for sexy console font | ||
## Usage | ||
## CLI Usage | ||
Using the CLI is easy. | ||
Read more in the [root repo](../). | ||
``` | ||
Usage: cfonts "<value>" [option1] <input1> [option2] <input1>,<input2> [option3] etc... | ||
``` | ||
At any point you can run the *help* command to get a full list of commands and | ||
how to use them. | ||
## Tests | ||
```shell | ||
$ cfonts --help | ||
``` | ||
This package is tested on the below platform and node combinations as part of our [CI](https://github.com/dominikwilkowski/cfonts/tree/released/.github/workflows/testing.yml). | ||
| Platform | Node | | ||
|----------|------| | ||
| Linux | v12 | | ||
| Linux | v14 | | ||
| Linux | v16 | | ||
| OSX | v10 | | ||
| OSX | v12 | | ||
| OSX | v16 | | ||
| Windows | v10 | | ||
| Windows | v12 | | ||
| Windows | v16 | | ||
## Supported Characters | ||
### Unit tests | ||
| | | | | | ||
|-----|-----|-----|-------------| | ||
| `A` | `P` | `4` | `$` | | ||
| `B` | `Q` | `5` | `%` | | ||
| `C` | `R` | `6` | `&` | | ||
| `D` | `S` | `7` | `(` | | ||
| `E` | `T` | `8` | `)` | | ||
| `F` | `U` | `9` | `/` | | ||
| `G` | `V` | `!` | `:` | | ||
| `H` | `W` | `?` | `;` | | ||
| `I` | `X` | `.` | `,` | | ||
| `J` | `Y` | `+` | `'` | | ||
| `K` | `Z` | `-` | `"` | | ||
| `L` | `0` | `_` | ` ` (space) | | ||
| `M` | `1` | `=` | | | ||
| `N` | `2` | `@` | | | ||
| `O` | `3` | `#` | | | ||
_The `|` character will be replaced with a line break_ | ||
## Options | ||
#### -h, --help | ||
Type: `<command>` | ||
Default value: `none` | ||
This shows a list of all available options. | ||
```shell | ||
$ cfonts --help | ||
``` | ||
![Help command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/help.png) | ||
#### -V, --version | ||
Type: `<command>` | ||
Default value: `none` | ||
This shows the installed version. | ||
```shell | ||
$ cfonts --version | ||
``` | ||
![Version command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/version.png) | ||
#### text | ||
Type: `<string>` | ||
Default value: `""` | ||
This is the "text input" to be converted into a nice font. | ||
The `|` character will be replaced with a line break. | ||
```shell | ||
$ cfonts "Hello world" | ||
``` | ||
![Text command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/text.png) | ||
#### -f, --font | ||
Type: `<string>` | ||
Default value: `"block"` | ||
This is the font face you want to use. So far this plugin ships with with following font faces: | ||
```shell | ||
$ cfonts "text" --font "chrome" | ||
``` | ||
![Font command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/font.png) | ||
- `block` [colors: 2] _(default)_ | ||
![block font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/block.png) | ||
- `slick` [colors: 2] | ||
![slick font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/slick.png) | ||
- `tiny` [colors: 1] | ||
![tiny font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/tiny.png) | ||
- `grid` [colors: 2] | ||
![grid font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/grid.png) | ||
- `pallet` [colors: 2] | ||
![pallet font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/pallet.png) | ||
- `shade` [colors: 2] | ||
![shade font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/shade.png) | ||
- `chrome` [colors: 3] | ||
![chrome font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/chrome.png) | ||
- `simple` [colors: 1] | ||
![simple font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/simple.png) | ||
- `simpleBlock` [colors: 1] | ||
![simple-block font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/simple-block.png) | ||
- `3d` [colors: 2] | ||
![3d font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/3d.png) | ||
- `simple3d` [colors: 1] | ||
![simple-3d font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/simple-3d.png) | ||
- `huge` [colors: 2] | ||
![huge font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/huge.png) | ||
- `console` [colors: 1] | ||
![console font style](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/console.png) | ||
#### -a, --align | ||
Type: `<string>` | ||
Default value: `"left"` | ||
You can align your text in the terminal with this option. Use the keywords below: | ||
- `left` _(default)_ | ||
- `center` | ||
- `right` | ||
- `top` _(Will be ignored if used with the spaceless option)_ | ||
- `bottom` _(Will be ignored if used with the spaceless option)_ | ||
```shell | ||
$ cfonts "text" --align "center" | ||
``` | ||
![Align command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/align.png) | ||
#### -c, --colors | ||
Type: `<string list>` | ||
Default value: `['system']` | ||
With this setting you can set the colors for your font. | ||
Use the below color strings built in by [chalk](https://github.com/chalk/chalk) or a hex color. | ||
Provide colors in a comma-separated string, eg: `red,blue`. _(no spaces)_ | ||
If you use a hex color make sure you include the `#` prefix. _(In the terminal wrap the hex in quotes)_ | ||
The `system` color falls back to the system color of your terminal. | ||
- `system` _(default)_ | ||
- `black` | ||
- `red` | ||
- `green` | ||
- `yellow` | ||
- `blue` | ||
- `magenta` | ||
- `cyan` | ||
- `white` | ||
- `gray` | ||
- `redBright` | ||
- `greenBright` | ||
- `yellowBright` | ||
- `blueBright` | ||
- `magentaBright` | ||
- `cyanBright` | ||
- `whiteBright` | ||
- `#ff8800` _(any valid hex color)_ | ||
- `#f80` _(short form is supported as well)_ | ||
```shell | ||
$ cfonts "text" --colors white,"#f80" | ||
``` | ||
![Colors command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/colors.png) | ||
#### -g, --gradient | ||
Type: `<string list>` | ||
Default value: `false` | ||
With this setting you can set a gradient over your output. | ||
This setting supersedes the color open. | ||
The gradient requires two colors, a start color and an end color from left to right. | ||
_(If you want to set your own colors for the gradient, use the [transition](#-t---transition-gradient) option.)_ | ||
CFonts will then generate a gradient through as many colors as it can find to make the output most impressive. | ||
Provide two colors in a comma-separated string, eg: `red,blue`. _(no spaces)_ | ||
If you use a hex color make sure you include the `#` prefix. _(In the terminal wrap the hex in quotes)_ | ||
- `black` | ||
- `red` | ||
- `green` | ||
- `yellow` | ||
- `blue` | ||
- `magenta` | ||
- `cyan` | ||
- `white` | ||
- `gray` | ||
- `grey` | ||
- `#ff8800` _(any valid hex color)_ | ||
- `#f80` _(short form is supported as well)_ | ||
```shell | ||
$ cfonts "text" --gradient red,"#f80" | ||
``` | ||
![Gradient command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/gradient.png) | ||
#### -i, --independent-gradient | ||
Type: `<boolean>` | ||
Default value: `false` | ||
Set this option to re-calculate the gradient colors for each new line. | ||
Only works in combination with the [gradient](#-g---gradient) option. | ||
```shell | ||
$ cfonts "text|next line" --gradient red,"#f80" --independent-gradient | ||
``` | ||
![Independent gradient command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/independent-gradient.png) | ||
#### -t, --transition-gradient | ||
Type: `<boolean>` | ||
Default value: `false` | ||
Set this option to generate your own gradients. | ||
Each color set in the gradient option will then be transitioned to directly. | ||
This option allows you to specify more than just two colors for your gradient. | ||
Only works in combination with the [gradient](#-g---gradient) option. | ||
```shell | ||
$ cfonts "text" --gradient red,"#f80",green,blue --transition-gradient | ||
``` | ||
![Independent gradient command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/transition-gradient.png) | ||
#### -b, --background | ||
Type: `<string>` | ||
Default value: `"transparent"` | ||
With this setting you can set the background colors for the output. Use the below color strings built in by [chalk](https://github.com/chalk/chalk). | ||
Provide the background color from the below supported list, eg: 'white' | ||
- `transparent` _(default)_ | ||
- `black` | ||
- `red` | ||
- `green` | ||
- `yellow` | ||
- `blue` | ||
- `magenta` | ||
- `cyan` | ||
- `white` | ||
- `blackBright` | ||
- `redBright` | ||
- `greenBright` | ||
- `yellowBright` | ||
- `blueBright` | ||
- `magentaBright` | ||
- `cyanBright` | ||
- `whiteBright` | ||
```shell | ||
$ cfonts "text" --background "Green" | ||
``` | ||
![Background command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/background.png) | ||
#### -l, --letter-spacing | ||
Type: `<integer>` | ||
Default value: `1` | ||
Set this option to widen the space between characters. | ||
```shell | ||
$ cfonts "text" --letter-spacing 2 | ||
``` | ||
![Letter spacing command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/letter-spacing.png) | ||
#### -z, --line-height | ||
Type: `<integer>` | ||
Default value: `1` | ||
Set this option to widen the space between lines. | ||
```shell | ||
$ cfonts "text" --line-height 2 | ||
``` | ||
![Line height command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/line-height.png) | ||
#### -s, --spaceless | ||
Type: `<boolean>` | ||
Default value: `false` | ||
Set this option to false if you don't want the plugin to insert two empty lines on top and on the bottom of the output. | ||
```shell | ||
$ cfonts "text" --spaceless | ||
``` | ||
![Spaceless command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/spaceless.png) | ||
#### -m, --max-length | ||
Type: `<integer>` | ||
Default value: `0` | ||
This option sets the maximum characters that will be printed on one line. | ||
CFonts detects the size of your terminal but you can opt out and determine your own max width. | ||
`0` means no max width and the text will break at the edge of the terminal window. | ||
```shell | ||
$ cfonts "text" --max-length 15 | ||
``` | ||
![Max length command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/max-length.png) | ||
#### -e, --env | ||
Type: `<string>` | ||
Default value: `node` | ||
This option lets you use CFonts to generate HTML instead of ANSI code. | ||
Note that `max-length` won't be automatically detected anymore and you will have to supply it if you want the text to wrap. | ||
Best used in a node script. | ||
```js | ||
const CFonts = require('cfonts'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const output = CFonts.render('My text', { | ||
colors: ['white'], | ||
gradient: ['cyan', 'red'], | ||
background: 'black', | ||
space: false, | ||
env: 'browser', | ||
}); | ||
fs.writeFileSync( | ||
path.normalize(`${ __dirname }/test.html`), | ||
output.string, | ||
{ | ||
encoding: 'utf8', | ||
} | ||
); | ||
``` | ||
![Max length command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/released/img/env.png) | ||
## Consistency | ||
[Chalk](https://github.com/chalk/chalk) detects what colors are supported on your platform. | ||
It sets a [level of support](https://github.com/chalk/chalk#256-and-truecolor-color-support) automatically. | ||
In CFonts you can override this by passing in the `FORCE_COLOR` environment variable. | ||
```shell | ||
FORCE_COLOR=3 cfonts "hello world" -c "#0088ff" | ||
``` | ||
## Contributing | ||
To build the repo install dependencies via: | ||
_(Since we ship a `yarn.lock` file please use [`yarn`](https://yarnpkg.com/) for development.)_ | ||
```shell | ||
yarn | ||
``` | ||
and run the watch to continuously transpile the code. | ||
```shell | ||
yarn watch | ||
``` | ||
Please look at the coding style and work with it, not against it ;) | ||
## Tests | ||
This package is tested on the below platform and node combinations as part of our [CI](https://github.com/dominikwilkowski/cfonts/tree/released/.travis.yml). | ||
| Platform | Node | | ||
|----------|--------| | ||
| Linux | v10 | | ||
| Linux | v12 | | ||
| Linux | latest | | ||
| OSX | v10 | | ||
| OSX | v12 | | ||
| OSX | latest | | ||
| Windows | v10 | | ||
| Windows | v12 | | ||
| Windows | latest | | ||
### Unit tests | ||
The package comes with a bunch of [unit tests](https://github.com/dominikwilkowski/cfonts/tree/released/test/unit) that aim to cover 100% of the code base. | ||
For more details about the code coverage check out [coveralls](https://coveralls.io/github/dominikwilkowski/cfonts?branch=released). | ||
```shell | ||
```sh | ||
npm run test:unit | ||
@@ -488,7 +116,8 @@ ``` | ||
### Type tests | ||
Since the code base uses [JSDocs](https://jsdoc.app/) we use [typescript](https://www.typescriptlang.org/) to test the inferred types from those comments. | ||
Typescript [supports JSDocs](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc) and we use it in our | ||
[test](https://github.com/dominikwilkowski/cfonts/blob/released/package.json#L38). | ||
[test](https://github.com/dominikwilkowski/cfonts/blob/released/nodejs/package.json#L37). | ||
```shell | ||
```sh | ||
npm run test:types | ||
@@ -498,5 +127,6 @@ ``` | ||
### Font file test | ||
There is also a [test suite](https://github.com/dominikwilkowski/cfonts/blob/released/test/fonttest.js) for font files. | ||
```shell | ||
There is also a [test suite](https://github.com/dominikwilkowski/cfonts/blob/released/nodejs/test/fonttest.js) for font files. | ||
```sh | ||
npm run test:fonts | ||
@@ -514,5 +144,6 @@ ``` | ||
### All tests | ||
Run all tests via: | ||
```shell | ||
```sh | ||
npm run test | ||
@@ -522,3 +153,23 @@ ``` | ||
## Contributing | ||
To build the repo install dependencies via: | ||
_(Since we ship a `yarn.lock` file please use [`yarn`](https://yarnpkg.com/) for development.)_ | ||
```sh | ||
yarn | ||
``` | ||
and run the watch to continuously transpile the code. | ||
```sh | ||
yarn watch | ||
``` | ||
Please look at the coding style and work with it, not against it ;) | ||
## Release History | ||
* 3.0.0 - Added rust library port, aligned APIs, added hex background colors, fixed minor alignment bugs, updated license from GPLv2 to GPLv3 | ||
* 2.10.1 - bumped dependencies | ||
@@ -561,3 +212,3 @@ * 2.10.0 - bumped dependencies, added typescript definitions into npm bundle | ||
* 2.1.1 - fixed size detection in non-tty environments | ||
* 2.1.0 - rebuilt cfonts with pure functions, made colors case-insensitive | ||
* 2.1.0 - rebuilt `cfonts` with pure functions, made colors case-insensitive | ||
* 2.0.1 - fixed terminal width detection | ||
@@ -589,2 +240,4 @@ * 2.0.0 - added tests, split into more pure functions | ||
## License | ||
Copyright (c) 2018 Dominik Wilkowski. Licensed under the [GNU GPLv2](https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE). | ||
Copyright (c) 2022 Dominik Wilkowski. | ||
Licensed under the [GNU GPLv3](https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
2
8637
269477
10
233
9
+ Addedsupports-color@^8
+ Addedsupports-color@8.1.1(transitive)
- Removedchalk@^4
- Removedansi-styles@4.3.0(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedsupports-color@7.2.0(transitive)