update
This commit is contained in:
+105
-80
@@ -1,5 +1,5 @@
|
||||
import {LiteralUnion} from 'type-fest';
|
||||
import cliBoxes, {BoxStyle} from 'cli-boxes';
|
||||
import {BoxStyle, Boxes} from 'cli-boxes';
|
||||
|
||||
declare namespace boxen {
|
||||
/**
|
||||
@@ -38,33 +38,33 @@ declare namespace boxen {
|
||||
Color of the box border.
|
||||
*/
|
||||
readonly borderColor?: LiteralUnion<
|
||||
| 'black'
|
||||
| 'red'
|
||||
| 'green'
|
||||
| 'yellow'
|
||||
| 'blue'
|
||||
| 'magenta'
|
||||
| 'cyan'
|
||||
| 'white'
|
||||
| 'gray'
|
||||
| 'grey'
|
||||
| 'blackBright'
|
||||
| 'redBright'
|
||||
| 'greenBright'
|
||||
| 'yellowBright'
|
||||
| 'blueBright'
|
||||
| 'magentaBright'
|
||||
| 'cyanBright'
|
||||
| 'whiteBright',
|
||||
string
|
||||
| 'black'
|
||||
| 'red'
|
||||
| 'green'
|
||||
| 'yellow'
|
||||
| 'blue'
|
||||
| 'magenta'
|
||||
| 'cyan'
|
||||
| 'white'
|
||||
| 'gray'
|
||||
| 'grey'
|
||||
| 'blackBright'
|
||||
| 'redBright'
|
||||
| 'greenBright'
|
||||
| 'yellowBright'
|
||||
| 'blueBright'
|
||||
| 'magentaBright'
|
||||
| 'cyanBright'
|
||||
| 'whiteBright',
|
||||
string
|
||||
>;
|
||||
|
||||
/**
|
||||
Style of the box border.
|
||||
|
||||
@default BorderStyle.Single
|
||||
@default 'single'
|
||||
*/
|
||||
readonly borderStyle?: BorderStyle | CustomBorderStyle;
|
||||
readonly borderStyle?: keyof Boxes | CustomBorderStyle;
|
||||
|
||||
/**
|
||||
Reduce opacity of the border.
|
||||
@@ -98,78 +98,103 @@ declare namespace boxen {
|
||||
Color of the background.
|
||||
*/
|
||||
readonly backgroundColor?: LiteralUnion<
|
||||
| 'black'
|
||||
| 'red'
|
||||
| 'green'
|
||||
| 'yellow'
|
||||
| 'blue'
|
||||
| 'magenta'
|
||||
| 'cyan'
|
||||
| 'white'
|
||||
| 'blackBright'
|
||||
| 'redBright'
|
||||
| 'greenBright'
|
||||
| 'yellowBright'
|
||||
| 'blueBright'
|
||||
| 'magentaBright'
|
||||
| 'cyanBright'
|
||||
| 'whiteBright',
|
||||
string
|
||||
| 'black'
|
||||
| 'red'
|
||||
| 'green'
|
||||
| 'yellow'
|
||||
| 'blue'
|
||||
| 'magenta'
|
||||
| 'cyan'
|
||||
| 'white'
|
||||
| 'blackBright'
|
||||
| 'redBright'
|
||||
| 'greenBright'
|
||||
| 'yellowBright'
|
||||
| 'blueBright'
|
||||
| 'magentaBright'
|
||||
| 'cyanBright'
|
||||
| 'whiteBright',
|
||||
string
|
||||
>;
|
||||
|
||||
/**
|
||||
Align the text in the box based on the widest line.
|
||||
|
||||
@default 'left'
|
||||
@deprecated Use `textAlignment` instead.
|
||||
*/
|
||||
readonly align?: 'left' | 'right' | 'center';
|
||||
|
||||
/**
|
||||
Align the text in the box based on the widest line.
|
||||
|
||||
@default 'left'
|
||||
*/
|
||||
readonly textAlignment?: 'left' | 'right' | 'center';
|
||||
|
||||
/**
|
||||
Display a title at the top of the box.
|
||||
If needed, the box will horizontally expand to fit the title.
|
||||
|
||||
@example
|
||||
```
|
||||
console.log(boxen('foo bar', {title: 'example'}));
|
||||
// ┌ example ┐
|
||||
// │foo bar │
|
||||
// └─────────┘
|
||||
```
|
||||
*/
|
||||
readonly title?: string;
|
||||
|
||||
/**
|
||||
Align the title in the top bar.
|
||||
|
||||
@default 'left'
|
||||
|
||||
@example
|
||||
```
|
||||
console.log(boxen('foo bar foo bar', {title: 'example', titleAlignment: 'center'}));
|
||||
// ┌─── example ───┐
|
||||
// │foo bar foo bar│
|
||||
// └───────────────┘
|
||||
|
||||
console.log(boxen('foo bar foo bar', {title: 'example', titleAlignment: 'right'}));
|
||||
// ┌────── example ┐
|
||||
// │foo bar foo bar│
|
||||
// └───────────────┘
|
||||
```
|
||||
*/
|
||||
readonly titleAlignment?: 'left' | 'right' | 'center';
|
||||
}
|
||||
}
|
||||
|
||||
declare const enum BorderStyle {
|
||||
Single = 'single',
|
||||
Double = 'double',
|
||||
Round = 'round',
|
||||
Bold = 'bold',
|
||||
SingleDouble = 'singleDouble',
|
||||
DoubleSingle = 'doubleSingle',
|
||||
Classic = 'classic'
|
||||
}
|
||||
/**
|
||||
Creates a box in the terminal.
|
||||
|
||||
declare const boxen: {
|
||||
/**
|
||||
Creates a box in the terminal.
|
||||
@param text - The text inside the box.
|
||||
@returns The box.
|
||||
|
||||
@param text - The text inside the box.
|
||||
@returns The box.
|
||||
@example
|
||||
```
|
||||
import boxen = require('boxen');
|
||||
|
||||
@example
|
||||
```
|
||||
import boxen = require('boxen');
|
||||
console.log(boxen('unicorn', {padding: 1}));
|
||||
// ┌─────────────┐
|
||||
// │ │
|
||||
// │ unicorn │
|
||||
// │ │
|
||||
// └─────────────┘
|
||||
|
||||
console.log(boxen('unicorn', {padding: 1}));
|
||||
// ┌─────────────┐
|
||||
// │ │
|
||||
// │ unicorn │
|
||||
// │ │
|
||||
// └─────────────┘
|
||||
|
||||
console.log(boxen('unicorn', {padding: 1, margin: 1, borderStyle: 'double'}));
|
||||
//
|
||||
// ╔═════════════╗
|
||||
// ║ ║
|
||||
// ║ unicorn ║
|
||||
// ║ ║
|
||||
// ╚═════════════╝
|
||||
//
|
||||
```
|
||||
*/
|
||||
(text: string, options?: boxen.Options): string;
|
||||
|
||||
/**
|
||||
Border styles from [`cli-boxes`](https://github.com/sindresorhus/cli-boxes).
|
||||
*/
|
||||
BorderStyle: typeof BorderStyle;
|
||||
};
|
||||
console.log(boxen('unicorn', {padding: 1, margin: 1, borderStyle: 'double'}));
|
||||
//
|
||||
// ╔═════════════╗
|
||||
// ║ ║
|
||||
// ║ unicorn ║
|
||||
// ║ ║
|
||||
// ╚═════════════╝
|
||||
//
|
||||
```
|
||||
*/
|
||||
declare const boxen: (text: string, options?: boxen.Options) => string;
|
||||
|
||||
export = boxen;
|
||||
|
||||
+182
-42
@@ -5,29 +5,42 @@ const widestLine = require('widest-line');
|
||||
const cliBoxes = require('cli-boxes');
|
||||
const camelCase = require('camelcase');
|
||||
const ansiAlign = require('ansi-align');
|
||||
const termSize = require('term-size');
|
||||
const wrapAnsi = require('wrap-ansi');
|
||||
|
||||
const getObject = detail => {
|
||||
let object;
|
||||
const NL = '\n';
|
||||
const PAD = ' ';
|
||||
|
||||
if (typeof detail === 'number') {
|
||||
object = {
|
||||
top: detail,
|
||||
right: detail * 3,
|
||||
bottom: detail,
|
||||
left: detail * 3
|
||||
};
|
||||
} else {
|
||||
object = {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
...detail
|
||||
};
|
||||
const terminalColumns = () => {
|
||||
const {env, stdout, stderr} = process;
|
||||
|
||||
if (stdout && stdout.columns) {
|
||||
return stdout.columns;
|
||||
}
|
||||
|
||||
return object;
|
||||
if (stderr && stderr.columns) {
|
||||
return stderr.columns;
|
||||
}
|
||||
|
||||
if (env.COLUMNS) {
|
||||
return Number.parseInt(env.COLUMNS, 10);
|
||||
}
|
||||
|
||||
return 80;
|
||||
};
|
||||
|
||||
const getObject = detail => {
|
||||
return typeof detail === 'number' ? {
|
||||
top: detail,
|
||||
right: detail * 3,
|
||||
bottom: detail,
|
||||
left: detail * 3
|
||||
} : {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
...detail
|
||||
};
|
||||
};
|
||||
|
||||
const getBorderChars = borderStyle => {
|
||||
@@ -61,7 +74,109 @@ const getBorderChars = borderStyle => {
|
||||
return chararacters;
|
||||
};
|
||||
|
||||
const isHex = color => color.match(/^#[0-f]{3}(?:[0-f]{3})?$/i);
|
||||
const makeTitle = (text, horizontal, alignement) => {
|
||||
let title = '';
|
||||
|
||||
const textWidth = stringWidth(text);
|
||||
|
||||
switch (alignement) {
|
||||
case 'left':
|
||||
title = text + horizontal.slice(textWidth);
|
||||
break;
|
||||
case 'right':
|
||||
title = horizontal.slice(textWidth) + text;
|
||||
break;
|
||||
default:
|
||||
horizontal = horizontal.slice(textWidth);
|
||||
|
||||
if (horizontal.length % 2 === 1) { // This is needed in case the length is odd
|
||||
horizontal = horizontal.slice(Math.floor(horizontal.length / 2));
|
||||
title = horizontal.slice(1) + text + horizontal; // We reduce the left part of one character to avoid the bar to go beyond its limit
|
||||
} else {
|
||||
horizontal = horizontal.slice(horizontal.length / 2);
|
||||
title = horizontal + text + horizontal;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return title;
|
||||
};
|
||||
|
||||
const makeContentText = (text, padding, columns, align) => {
|
||||
text = ansiAlign(text, {align});
|
||||
let lines = text.split(NL);
|
||||
const textWidth = widestLine(text);
|
||||
|
||||
const max = columns - padding.left - padding.right;
|
||||
|
||||
if (textWidth > max) {
|
||||
const newLines = [];
|
||||
for (const line of lines) {
|
||||
const createdLines = wrapAnsi(line, max, {hard: true});
|
||||
const alignedLines = ansiAlign(createdLines, {align});
|
||||
const alignedLinesArray = alignedLines.split('\n');
|
||||
const longestLength = Math.max(...alignedLinesArray.map(s => stringWidth(s)));
|
||||
|
||||
for (const alignedLine of alignedLinesArray) {
|
||||
let paddedLine;
|
||||
switch (align) {
|
||||
case 'center':
|
||||
paddedLine = PAD.repeat((max - longestLength) / 2) + alignedLine;
|
||||
break;
|
||||
case 'right':
|
||||
paddedLine = PAD.repeat(max - longestLength) + alignedLine;
|
||||
break;
|
||||
default:
|
||||
paddedLine = alignedLine;
|
||||
break;
|
||||
}
|
||||
|
||||
newLines.push(paddedLine);
|
||||
}
|
||||
}
|
||||
|
||||
lines = newLines;
|
||||
}
|
||||
|
||||
if (align === 'center' && textWidth < max) {
|
||||
lines = lines.map(line => PAD.repeat((max - textWidth) / 2) + line);
|
||||
} else if (align === 'right' && textWidth < max) {
|
||||
lines = lines.map(line => PAD.repeat(max - textWidth) + line);
|
||||
}
|
||||
|
||||
const paddingLeft = PAD.repeat(padding.left);
|
||||
const paddingRight = PAD.repeat(padding.right);
|
||||
|
||||
lines = lines.map(line => paddingLeft + line + paddingRight);
|
||||
|
||||
lines = lines.map(line => {
|
||||
if (columns - stringWidth(line) > 0) {
|
||||
switch (align) {
|
||||
case 'center':
|
||||
return line + PAD.repeat(columns - stringWidth(line));
|
||||
case 'right':
|
||||
return line + PAD.repeat(columns - stringWidth(line));
|
||||
default:
|
||||
return line + PAD.repeat(columns - stringWidth(line));
|
||||
}
|
||||
}
|
||||
|
||||
return line;
|
||||
});
|
||||
|
||||
if (padding.top > 0) {
|
||||
lines = new Array(padding.top).fill(PAD.repeat(columns)).concat(lines);
|
||||
}
|
||||
|
||||
if (padding.bottom > 0) {
|
||||
lines = lines.concat(new Array(padding.bottom).fill(PAD.repeat(columns)));
|
||||
}
|
||||
|
||||
return lines.join(NL);
|
||||
};
|
||||
|
||||
const isHex = color => color.match(/^#(?:[0-f]{3}){1,2}$/i);
|
||||
const isColorValid = color => typeof color === 'string' && ((chalk[color]) || isHex(color));
|
||||
const getColorFn = color => isHex(color) ? chalk.hex(color) : chalk[color];
|
||||
const getBGColorFn = color => isHex(color) ? chalk.bgHex(color) : chalk[camelCase(['bg', color])];
|
||||
@@ -71,11 +186,19 @@ module.exports = (text, options) => {
|
||||
padding: 0,
|
||||
borderStyle: 'single',
|
||||
dimBorder: false,
|
||||
align: 'left',
|
||||
textAlignment: 'left',
|
||||
float: 'left',
|
||||
titleAlignment: 'left',
|
||||
...options
|
||||
};
|
||||
|
||||
// This option is deprecated
|
||||
if (options.align) {
|
||||
options.textAlignment = options.align;
|
||||
}
|
||||
|
||||
const BORDERS_WIDTH = 2;
|
||||
|
||||
if (options.borderColor && !isColorValid(options.borderColor)) {
|
||||
throw new Error(`${options.borderColor} is not a valid borderColor`);
|
||||
}
|
||||
@@ -95,45 +218,62 @@ module.exports = (text, options) => {
|
||||
|
||||
const colorizeContent = content => options.backgroundColor ? getBGColorFn(options.backgroundColor)(content) : content;
|
||||
|
||||
text = ansiAlign(text, {align: options.align});
|
||||
const columns = terminalColumns();
|
||||
|
||||
const NL = '\n';
|
||||
const PAD = ' ';
|
||||
let contentWidth = widestLine(wrapAnsi(text, columns - BORDERS_WIDTH, {hard: true, trim: false})) + padding.left + padding.right;
|
||||
|
||||
let lines = text.split(NL);
|
||||
// This prevents the title bar to exceed the console's width
|
||||
let title = options.title && options.title.slice(0, columns - 4 - margin.left - margin.right);
|
||||
|
||||
if (padding.top > 0) {
|
||||
lines = new Array(padding.top).fill('').concat(lines);
|
||||
if (title) {
|
||||
title = ` ${title} `;
|
||||
// Make the box larger to fit a larger title
|
||||
if (stringWidth(title) > contentWidth) {
|
||||
contentWidth = stringWidth(title);
|
||||
}
|
||||
}
|
||||
|
||||
if (padding.bottom > 0) {
|
||||
lines = lines.concat(new Array(padding.bottom).fill(''));
|
||||
if ((margin.left && margin.right) && contentWidth + BORDERS_WIDTH + margin.left + margin.right > columns) {
|
||||
// Let's assume we have margins: left = 3, right = 5, in total = 8
|
||||
const spaceForMargins = columns - contentWidth - BORDERS_WIDTH;
|
||||
// Let's assume we have space = 4
|
||||
const multiplier = spaceForMargins / (margin.left + margin.right);
|
||||
// Here: multiplier = 4/8 = 0.5
|
||||
margin.left = Math.max(0, Math.floor(margin.left * multiplier));
|
||||
margin.right = Math.max(0, Math.floor(margin.right * multiplier));
|
||||
// Left: 3 * 0.5 = 1.5 -> 1
|
||||
// Right: 6 * 0.5 = 3
|
||||
}
|
||||
|
||||
const contentWidth = widestLine(text) + padding.left + padding.right;
|
||||
const paddingLeft = PAD.repeat(padding.left);
|
||||
const {columns} = termSize();
|
||||
// Prevent content from exceeding the console's width
|
||||
contentWidth = Math.min(contentWidth, columns - BORDERS_WIDTH - margin.left - margin.right);
|
||||
|
||||
text = makeContentText(text, padding, contentWidth, options.textAlignment);
|
||||
|
||||
let marginLeft = PAD.repeat(margin.left);
|
||||
|
||||
if (options.float === 'center') {
|
||||
const padWidth = Math.max((columns - contentWidth) / 2, 0);
|
||||
marginLeft = PAD.repeat(padWidth);
|
||||
const marginWidth = Math.max((columns - contentWidth - BORDERS_WIDTH) / 2, 0);
|
||||
marginLeft = PAD.repeat(marginWidth);
|
||||
} else if (options.float === 'right') {
|
||||
const padWidth = Math.max(columns - contentWidth - margin.right - 2, 0);
|
||||
marginLeft = PAD.repeat(padWidth);
|
||||
const marginWidth = Math.max(columns - contentWidth - margin.right - BORDERS_WIDTH, 0);
|
||||
marginLeft = PAD.repeat(marginWidth);
|
||||
}
|
||||
|
||||
const horizontal = chars.horizontal.repeat(contentWidth);
|
||||
const top = colorizeBorder(NL.repeat(margin.top) + marginLeft + chars.topLeft + horizontal + chars.topRight);
|
||||
const top = colorizeBorder(NL.repeat(margin.top) + marginLeft + chars.topLeft + (title ? makeTitle(title, horizontal, options.titleAlignment) : horizontal) + chars.topRight);
|
||||
const bottom = colorizeBorder(marginLeft + chars.bottomLeft + horizontal + chars.bottomRight + NL.repeat(margin.bottom));
|
||||
const side = colorizeBorder(chars.vertical);
|
||||
|
||||
const middle = lines.map(line => {
|
||||
const paddingRight = PAD.repeat(contentWidth - stringWidth(line) - padding.left);
|
||||
return marginLeft + side + colorizeContent(paddingLeft + line + paddingRight) + side;
|
||||
}).join(NL);
|
||||
const LINE_SEPARATOR = (contentWidth + BORDERS_WIDTH + margin.left >= columns) ? '' : NL;
|
||||
|
||||
return top + NL + middle + NL + bottom;
|
||||
const lines = text.split(NL);
|
||||
|
||||
const middle = lines.map(line => {
|
||||
return marginLeft + side + colorizeContent(line) + side;
|
||||
}).join(LINE_SEPARATOR);
|
||||
|
||||
return top + LINE_SEPARATOR + middle + LINE_SEPARATOR + bottom;
|
||||
};
|
||||
|
||||
module.exports._borderStyles = cliBoxes;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
+150
-2
@@ -1,4 +1,152 @@
|
||||
import * as cssColors from 'color-name';
|
||||
declare type CSSColor =
|
||||
| 'aliceblue'
|
||||
| 'antiquewhite'
|
||||
| 'aqua'
|
||||
| 'aquamarine'
|
||||
| 'azure'
|
||||
| 'beige'
|
||||
| 'bisque'
|
||||
| 'black'
|
||||
| 'blanchedalmond'
|
||||
| 'blue'
|
||||
| 'blueviolet'
|
||||
| 'brown'
|
||||
| 'burlywood'
|
||||
| 'cadetblue'
|
||||
| 'chartreuse'
|
||||
| 'chocolate'
|
||||
| 'coral'
|
||||
| 'cornflowerblue'
|
||||
| 'cornsilk'
|
||||
| 'crimson'
|
||||
| 'cyan'
|
||||
| 'darkblue'
|
||||
| 'darkcyan'
|
||||
| 'darkgoldenrod'
|
||||
| 'darkgray'
|
||||
| 'darkgreen'
|
||||
| 'darkgrey'
|
||||
| 'darkkhaki'
|
||||
| 'darkmagenta'
|
||||
| 'darkolivegreen'
|
||||
| 'darkorange'
|
||||
| 'darkorchid'
|
||||
| 'darkred'
|
||||
| 'darksalmon'
|
||||
| 'darkseagreen'
|
||||
| 'darkslateblue'
|
||||
| 'darkslategray'
|
||||
| 'darkslategrey'
|
||||
| 'darkturquoise'
|
||||
| 'darkviolet'
|
||||
| 'deeppink'
|
||||
| 'deepskyblue'
|
||||
| 'dimgray'
|
||||
| 'dimgrey'
|
||||
| 'dodgerblue'
|
||||
| 'firebrick'
|
||||
| 'floralwhite'
|
||||
| 'forestgreen'
|
||||
| 'fuchsia'
|
||||
| 'gainsboro'
|
||||
| 'ghostwhite'
|
||||
| 'gold'
|
||||
| 'goldenrod'
|
||||
| 'gray'
|
||||
| 'green'
|
||||
| 'greenyellow'
|
||||
| 'grey'
|
||||
| 'honeydew'
|
||||
| 'hotpink'
|
||||
| 'indianred'
|
||||
| 'indigo'
|
||||
| 'ivory'
|
||||
| 'khaki'
|
||||
| 'lavender'
|
||||
| 'lavenderblush'
|
||||
| 'lawngreen'
|
||||
| 'lemonchiffon'
|
||||
| 'lightblue'
|
||||
| 'lightcoral'
|
||||
| 'lightcyan'
|
||||
| 'lightgoldenrodyellow'
|
||||
| 'lightgray'
|
||||
| 'lightgreen'
|
||||
| 'lightgrey'
|
||||
| 'lightpink'
|
||||
| 'lightsalmon'
|
||||
| 'lightseagreen'
|
||||
| 'lightskyblue'
|
||||
| 'lightslategray'
|
||||
| 'lightslategrey'
|
||||
| 'lightsteelblue'
|
||||
| 'lightyellow'
|
||||
| 'lime'
|
||||
| 'limegreen'
|
||||
| 'linen'
|
||||
| 'magenta'
|
||||
| 'maroon'
|
||||
| 'mediumaquamarine'
|
||||
| 'mediumblue'
|
||||
| 'mediumorchid'
|
||||
| 'mediumpurple'
|
||||
| 'mediumseagreen'
|
||||
| 'mediumslateblue'
|
||||
| 'mediumspringgreen'
|
||||
| 'mediumturquoise'
|
||||
| 'mediumvioletred'
|
||||
| 'midnightblue'
|
||||
| 'mintcream'
|
||||
| 'mistyrose'
|
||||
| 'moccasin'
|
||||
| 'navajowhite'
|
||||
| 'navy'
|
||||
| 'oldlace'
|
||||
| 'olive'
|
||||
| 'olivedrab'
|
||||
| 'orange'
|
||||
| 'orangered'
|
||||
| 'orchid'
|
||||
| 'palegoldenrod'
|
||||
| 'palegreen'
|
||||
| 'paleturquoise'
|
||||
| 'palevioletred'
|
||||
| 'papayawhip'
|
||||
| 'peachpuff'
|
||||
| 'peru'
|
||||
| 'pink'
|
||||
| 'plum'
|
||||
| 'powderblue'
|
||||
| 'purple'
|
||||
| 'rebeccapurple'
|
||||
| 'red'
|
||||
| 'rosybrown'
|
||||
| 'royalblue'
|
||||
| 'saddlebrown'
|
||||
| 'salmon'
|
||||
| 'sandybrown'
|
||||
| 'seagreen'
|
||||
| 'seashell'
|
||||
| 'sienna'
|
||||
| 'silver'
|
||||
| 'skyblue'
|
||||
| 'slateblue'
|
||||
| 'slategray'
|
||||
| 'slategrey'
|
||||
| 'snow'
|
||||
| 'springgreen'
|
||||
| 'steelblue'
|
||||
| 'tan'
|
||||
| 'teal'
|
||||
| 'thistle'
|
||||
| 'tomato'
|
||||
| 'turquoise'
|
||||
| 'violet'
|
||||
| 'wheat'
|
||||
| 'white'
|
||||
| 'whitesmoke'
|
||||
| 'yellow'
|
||||
| 'yellowgreen';
|
||||
|
||||
declare namespace ansiStyles {
|
||||
interface ColorConvert {
|
||||
@@ -21,7 +169,7 @@ declare namespace ansiStyles {
|
||||
/**
|
||||
@param keyword - A CSS color name.
|
||||
*/
|
||||
keyword(keyword: keyof typeof cssColors): string;
|
||||
keyword(keyword: CSSColor): string;
|
||||
|
||||
/**
|
||||
The HSL color space.
|
||||
|
||||
+12
-13
@@ -1,32 +1,32 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"ansi-styles@4.2.1",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"ansi-styles@4.3.0",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "ansi-styles@4.2.1",
|
||||
"_id": "ansi-styles@4.2.1",
|
||||
"_from": "ansi-styles@4.3.0",
|
||||
"_id": "ansi-styles@4.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
|
||||
"_integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"_location": "/boxen/ansi-styles",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "ansi-styles@4.2.1",
|
||||
"raw": "ansi-styles@4.3.0",
|
||||
"name": "ansi-styles",
|
||||
"escapedName": "ansi-styles",
|
||||
"rawSpec": "4.2.1",
|
||||
"rawSpec": "4.3.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "4.2.1"
|
||||
"fetchSpec": "4.3.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/boxen/chalk"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
|
||||
"_spec": "4.2.1",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"_spec": "4.3.0",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
@@ -36,7 +36,6 @@
|
||||
"url": "https://github.com/chalk/ansi-styles/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/color-name": "^1.1.1",
|
||||
"color-convert": "^2.0.1"
|
||||
},
|
||||
"description": "ANSI escape codes for styling strings in the terminal",
|
||||
@@ -88,5 +87,5 @@
|
||||
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor",
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"version": "4.2.1"
|
||||
"version": "4.3.0"
|
||||
}
|
||||
|
||||
+4
-10
@@ -145,14 +145,8 @@ style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color backgroun
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
---
|
||||
## For enterprise
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
declare namespace camelcase {
|
||||
interface Options {
|
||||
/**
|
||||
Uppercase the first character: `foo-bar` → `FooBar`.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly pascalCase?: boolean;
|
||||
|
||||
/**
|
||||
Preserve the consecutive uppercase characters: `foo-BAR` → `FooBAR`.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly preserveConsecutiveUppercase?: boolean;
|
||||
|
||||
/**
|
||||
The locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an array, the best available locale is used.
|
||||
|
||||
Setting `locale: false` ignores the platform locale and uses the [Unicode Default Case Conversion](https://unicode-org.github.io/icu/userguide/transforms/casemappings.html#simple-single-character-case-mapping) algorithm.
|
||||
|
||||
Default: The host environment’s current locale.
|
||||
|
||||
@example
|
||||
```
|
||||
import camelCase = require('camelcase');
|
||||
|
||||
camelCase('lorem-ipsum', {locale: 'en-US'});
|
||||
//=> 'loremIpsum'
|
||||
camelCase('lorem-ipsum', {locale: 'tr-TR'});
|
||||
//=> 'loremİpsum'
|
||||
camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
|
||||
//=> 'loremIpsum'
|
||||
camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
|
||||
//=> 'loremİpsum'
|
||||
```
|
||||
*/
|
||||
readonly locale?: false | string | readonly string[];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`.
|
||||
|
||||
Correctly handles Unicode strings.
|
||||
|
||||
@param input - String to convert to camel case.
|
||||
|
||||
@example
|
||||
```
|
||||
import camelCase = require('camelcase');
|
||||
|
||||
camelCase('foo-bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('foo_bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('Foo-Bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('розовый_пушистый_единорог');
|
||||
//=> 'розовыйПушистыйЕдинорог'
|
||||
|
||||
camelCase('Foo-Bar', {pascalCase: true});
|
||||
//=> 'FooBar'
|
||||
|
||||
camelCase('--foo.bar', {pascalCase: false});
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
|
||||
//=> 'fooBAR'
|
||||
|
||||
camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true}));
|
||||
//=> 'FooBAR'
|
||||
|
||||
camelCase('foo bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
console.log(process.argv[3]);
|
||||
//=> '--foo-bar'
|
||||
camelCase(process.argv[3]);
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase(['foo', 'bar']);
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase(['__foo__', '--bar'], {pascalCase: true});
|
||||
//=> 'FooBar'
|
||||
|
||||
camelCase(['foo', 'BAR'], {pascalCase: true, preserveConsecutiveUppercase: true})
|
||||
//=> 'FooBAR'
|
||||
|
||||
camelCase('lorem-ipsum', {locale: 'en-US'});
|
||||
//=> 'loremIpsum'
|
||||
```
|
||||
*/
|
||||
declare function camelcase(
|
||||
input: string | readonly string[],
|
||||
options?: camelcase.Options
|
||||
): string;
|
||||
|
||||
export = camelcase;
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
'use strict';
|
||||
|
||||
const UPPERCASE = /[\p{Lu}]/u;
|
||||
const LOWERCASE = /[\p{Ll}]/u;
|
||||
const LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
|
||||
const IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
|
||||
const SEPARATORS = /[_.\- ]+/;
|
||||
|
||||
const LEADING_SEPARATORS = new RegExp('^' + SEPARATORS.source);
|
||||
const SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, 'gu');
|
||||
const NUMBERS_AND_IDENTIFIER = new RegExp('\\d+' + IDENTIFIER.source, 'gu');
|
||||
|
||||
const preserveCamelCase = (string, toLowerCase, toUpperCase) => {
|
||||
let isLastCharLower = false;
|
||||
let isLastCharUpper = false;
|
||||
let isLastLastCharUpper = false;
|
||||
|
||||
for (let i = 0; i < string.length; i++) {
|
||||
const character = string[i];
|
||||
|
||||
if (isLastCharLower && UPPERCASE.test(character)) {
|
||||
string = string.slice(0, i) + '-' + string.slice(i);
|
||||
isLastCharLower = false;
|
||||
isLastLastCharUpper = isLastCharUpper;
|
||||
isLastCharUpper = true;
|
||||
i++;
|
||||
} else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character)) {
|
||||
string = string.slice(0, i - 1) + '-' + string.slice(i - 1);
|
||||
isLastLastCharUpper = isLastCharUpper;
|
||||
isLastCharUpper = false;
|
||||
isLastCharLower = true;
|
||||
} else {
|
||||
isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
|
||||
isLastLastCharUpper = isLastCharUpper;
|
||||
isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
};
|
||||
|
||||
const preserveConsecutiveUppercase = (input, toLowerCase) => {
|
||||
LEADING_CAPITAL.lastIndex = 0;
|
||||
|
||||
return input.replace(LEADING_CAPITAL, m1 => toLowerCase(m1));
|
||||
};
|
||||
|
||||
const postProcess = (input, toUpperCase) => {
|
||||
SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
|
||||
NUMBERS_AND_IDENTIFIER.lastIndex = 0;
|
||||
|
||||
return input.replace(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier))
|
||||
.replace(NUMBERS_AND_IDENTIFIER, m => toUpperCase(m));
|
||||
};
|
||||
|
||||
const camelCase = (input, options) => {
|
||||
if (!(typeof input === 'string' || Array.isArray(input))) {
|
||||
throw new TypeError('Expected the input to be `string | string[]`');
|
||||
}
|
||||
|
||||
options = {
|
||||
pascalCase: false,
|
||||
preserveConsecutiveUppercase: false,
|
||||
...options
|
||||
};
|
||||
|
||||
if (Array.isArray(input)) {
|
||||
input = input.map(x => x.trim())
|
||||
.filter(x => x.length)
|
||||
.join('-');
|
||||
} else {
|
||||
input = input.trim();
|
||||
}
|
||||
|
||||
if (input.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const toLowerCase = options.locale === false ?
|
||||
string => string.toLowerCase() :
|
||||
string => string.toLocaleLowerCase(options.locale);
|
||||
const toUpperCase = options.locale === false ?
|
||||
string => string.toUpperCase() :
|
||||
string => string.toLocaleUpperCase(options.locale);
|
||||
|
||||
if (input.length === 1) {
|
||||
return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
|
||||
}
|
||||
|
||||
const hasUpperCase = input !== toLowerCase(input);
|
||||
|
||||
if (hasUpperCase) {
|
||||
input = preserveCamelCase(input, toLowerCase, toUpperCase);
|
||||
}
|
||||
|
||||
input = input.replace(LEADING_SEPARATORS, '');
|
||||
|
||||
if (options.preserveConsecutiveUppercase) {
|
||||
input = preserveConsecutiveUppercase(input, toLowerCase);
|
||||
} else {
|
||||
input = toLowerCase(input);
|
||||
}
|
||||
|
||||
if (options.pascalCase) {
|
||||
input = toUpperCase(input.charAt(0)) + input.slice(1);
|
||||
}
|
||||
|
||||
return postProcess(input, toUpperCase);
|
||||
};
|
||||
|
||||
module.exports = camelCase;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = camelCase;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"camelcase@6.3.0",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "camelcase@6.3.0",
|
||||
"_id": "camelcase@6.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==",
|
||||
"_location": "/boxen/camelcase",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "camelcase@6.3.0",
|
||||
"name": "camelcase",
|
||||
"escapedName": "camelcase",
|
||||
"rawSpec": "6.3.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "6.3.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/boxen"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz",
|
||||
"_spec": "6.3.0",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/camelcase/issues"
|
||||
},
|
||||
"description": "Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`",
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.28.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"homepage": "https://github.com/sindresorhus/camelcase#readme",
|
||||
"keywords": [
|
||||
"camelcase",
|
||||
"camel-case",
|
||||
"camel",
|
||||
"case",
|
||||
"dash",
|
||||
"hyphen",
|
||||
"dot",
|
||||
"underscore",
|
||||
"separator",
|
||||
"string",
|
||||
"text",
|
||||
"convert",
|
||||
"pascalcase",
|
||||
"pascal-case"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "camelcase",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/camelcase.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"version": "6.3.0"
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
# camelcase
|
||||
|
||||
> Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`
|
||||
|
||||
Correctly handles Unicode strings.
|
||||
|
||||
If you use this on untrusted user input, don't forget to limit the length to something reasonable.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install camelcase
|
||||
```
|
||||
|
||||
*If you need to support Firefox < 78, stay on version 5 as version 6 uses regex features not available in Firefox < 78.*
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const camelCase = require('camelcase');
|
||||
|
||||
camelCase('foo-bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('foo_bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('Foo-Bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('розовый_пушистый_единорог');
|
||||
//=> 'розовыйПушистыйЕдинорог'
|
||||
|
||||
camelCase('Foo-Bar', {pascalCase: true});
|
||||
//=> 'FooBar'
|
||||
|
||||
camelCase('--foo.bar', {pascalCase: false});
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
|
||||
//=> 'fooBAR'
|
||||
|
||||
camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true}));
|
||||
//=> 'FooBAR'
|
||||
|
||||
camelCase('foo bar');
|
||||
//=> 'fooBar'
|
||||
|
||||
console.log(process.argv[3]);
|
||||
//=> '--foo-bar'
|
||||
camelCase(process.argv[3]);
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase(['foo', 'bar']);
|
||||
//=> 'fooBar'
|
||||
|
||||
camelCase(['__foo__', '--bar'], {pascalCase: true});
|
||||
//=> 'FooBar'
|
||||
|
||||
camelCase(['foo', 'BAR'], {pascalCase: true, preserveConsecutiveUppercase: true})
|
||||
//=> 'FooBAR'
|
||||
|
||||
camelCase('lorem-ipsum', {locale: 'en-US'});
|
||||
//=> 'loremIpsum'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### camelCase(input, options?)
|
||||
|
||||
#### input
|
||||
|
||||
Type: `string | string[]`
|
||||
|
||||
String to convert to camel case.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### pascalCase
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Uppercase the first character: `foo-bar` → `FooBar`
|
||||
|
||||
##### preserveConsecutiveUppercase
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Preserve the consecutive uppercase characters: `foo-BAR` → `FooBAR`.
|
||||
|
||||
##### locale
|
||||
|
||||
Type: `false | string | string[]`\
|
||||
Default: The host environment’s current locale.
|
||||
|
||||
The locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an array, the best available locale is used.
|
||||
|
||||
```js
|
||||
const camelCase = require('camelcase');
|
||||
|
||||
camelCase('lorem-ipsum', {locale: 'en-US'});
|
||||
//=> 'loremIpsum'
|
||||
|
||||
camelCase('lorem-ipsum', {locale: 'tr-TR'});
|
||||
//=> 'loremİpsum'
|
||||
|
||||
camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
|
||||
//=> 'loremIpsum'
|
||||
|
||||
camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
|
||||
//=> 'loremİpsum'
|
||||
```
|
||||
|
||||
Setting `locale: false` ignores the platform locale and uses the [Unicode Default Case Conversion](https://unicode-org.github.io/icu/userguide/transforms/casemappings.html#simple-single-character-case-mapping) algorithm:
|
||||
|
||||
```js
|
||||
const camelCase = require('camelcase');
|
||||
|
||||
// On a platform with 'tr-TR'
|
||||
|
||||
camelCase('lorem-ipsum');
|
||||
//=> 'loremİpsum'
|
||||
|
||||
camelCase('lorem-ipsum', {locale: false});
|
||||
//=> 'loremIpsum'
|
||||
```
|
||||
|
||||
## camelcase for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of camelcase and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-camelcase?utm_source=npm-camelcase&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
## Related
|
||||
|
||||
- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
|
||||
- [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase
|
||||
- [titleize](https://github.com/sindresorhus/titleize) - Capitalize every word in string
|
||||
- [humanize-string](https://github.com/sindresorhus/humanize-string) - Convert a camelized/dasherized/underscored string into a humanized one
|
||||
- [camelcase-keys](https://github.com/sindresorhus/camelcase-keys) - Convert object keys to camel case
|
||||
+34
-30
@@ -1,25 +1,3 @@
|
||||
declare const enum LevelEnum {
|
||||
/**
|
||||
All colors disabled.
|
||||
*/
|
||||
None = 0,
|
||||
|
||||
/**
|
||||
Basic 16 colors support.
|
||||
*/
|
||||
Basic = 1,
|
||||
|
||||
/**
|
||||
ANSI 256 colors support.
|
||||
*/
|
||||
Ansi256 = 2,
|
||||
|
||||
/**
|
||||
Truecolor 16 million colors support.
|
||||
*/
|
||||
TrueColor = 3
|
||||
}
|
||||
|
||||
/**
|
||||
Basic foreground colors.
|
||||
|
||||
@@ -89,22 +67,34 @@ declare type Modifiers =
|
||||
| 'visible';
|
||||
|
||||
declare namespace chalk {
|
||||
type Level = LevelEnum;
|
||||
/**
|
||||
Levels:
|
||||
- `0` - All colors disabled.
|
||||
- `1` - Basic 16 colors support.
|
||||
- `2` - ANSI 256 colors support.
|
||||
- `3` - Truecolor 16 million colors support.
|
||||
*/
|
||||
type Level = 0 | 1 | 2 | 3;
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
Specify the color support for Chalk.
|
||||
|
||||
By default, color support is automatically detected based on the environment.
|
||||
|
||||
Levels:
|
||||
- `0` - All colors disabled.
|
||||
- `1` - Basic 16 colors support.
|
||||
- `2` - ANSI 256 colors support.
|
||||
- `3` - Truecolor 16 million colors support.
|
||||
*/
|
||||
level?: Level;
|
||||
}
|
||||
|
||||
interface Instance {
|
||||
/**
|
||||
Return a new Chalk instance.
|
||||
*/
|
||||
new (options?: Options): Chalk;
|
||||
}
|
||||
/**
|
||||
Return a new Chalk instance.
|
||||
*/
|
||||
type Instance = new (options?: Options) => Chalk;
|
||||
|
||||
/**
|
||||
Detect whether the terminal supports color.
|
||||
@@ -147,6 +137,13 @@ declare namespace chalk {
|
||||
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
||||
`);
|
||||
```
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk = require('chalk');
|
||||
|
||||
log(chalk.red.bgBlack`2 + 3 = {bold ${2 + 3}}`)
|
||||
```
|
||||
*/
|
||||
(text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
||||
|
||||
@@ -161,7 +158,14 @@ declare namespace chalk {
|
||||
|
||||
/**
|
||||
The color support for Chalk.
|
||||
|
||||
By default, color support is automatically detected based on the environment.
|
||||
|
||||
Levels:
|
||||
- `0` - All colors disabled.
|
||||
- `1` - Basic 16 colors support.
|
||||
- `2` - ANSI 256 colors support.
|
||||
- `3` - Truecolor 16 million colors support.
|
||||
*/
|
||||
level: Level;
|
||||
|
||||
@@ -400,7 +404,7 @@ This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||
*/
|
||||
declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
|
||||
supportsColor: chalk.ColorSupport | false;
|
||||
Level: typeof LevelEnum;
|
||||
Level: chalk.Level;
|
||||
Color: Color;
|
||||
ForegroundColor: ForegroundColor;
|
||||
BackgroundColor: BackgroundColor;
|
||||
|
||||
+22
-17
@@ -1,32 +1,32 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"chalk@3.0.0",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"chalk@4.1.2",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "chalk@3.0.0",
|
||||
"_id": "chalk@3.0.0",
|
||||
"_from": "chalk@4.1.2",
|
||||
"_id": "chalk@4.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
|
||||
"_integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"_location": "/boxen/chalk",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "chalk@3.0.0",
|
||||
"raw": "chalk@4.1.2",
|
||||
"name": "chalk",
|
||||
"escapedName": "chalk",
|
||||
"rawSpec": "3.0.0",
|
||||
"rawSpec": "4.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.0.0"
|
||||
"fetchSpec": "4.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/boxen"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
|
||||
"_spec": "3.0.0",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
"_spec": "4.1.2",
|
||||
"_where": "/home/node/nuxt",
|
||||
"bugs": {
|
||||
"url": "https://github.com/chalk/chalk/issues"
|
||||
},
|
||||
@@ -38,21 +38,22 @@
|
||||
"devDependencies": {
|
||||
"ava": "^2.4.0",
|
||||
"coveralls": "^3.0.7",
|
||||
"execa": "^3.2.0",
|
||||
"execa": "^4.0.0",
|
||||
"import-fresh": "^3.1.0",
|
||||
"matcha": "^0.7.0",
|
||||
"nyc": "^14.1.1",
|
||||
"nyc": "^15.0.0",
|
||||
"resolve-from": "^5.0.0",
|
||||
"tsd": "^0.7.4",
|
||||
"xo": "^0.25.3"
|
||||
"xo": "^0.28.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
"node": ">=10"
|
||||
},
|
||||
"files": [
|
||||
"source",
|
||||
"index.d.ts"
|
||||
],
|
||||
"funding": "https://github.com/chalk/chalk?sponsor=1",
|
||||
"homepage": "https://github.com/chalk/chalk#readme",
|
||||
"keywords": [
|
||||
"color",
|
||||
@@ -88,11 +89,15 @@
|
||||
"bench": "matcha benchmark.js",
|
||||
"test": "xo && nyc ava && tsd"
|
||||
},
|
||||
"version": "3.0.0",
|
||||
"version": "4.1.2",
|
||||
"xo": {
|
||||
"rules": {
|
||||
"unicorn/prefer-string-slice": "off",
|
||||
"unicorn/prefer-includes": "off"
|
||||
"unicorn/prefer-includes": "off",
|
||||
"@typescript-eslint/member-ordering": "off",
|
||||
"no-redeclare": "off",
|
||||
"unicorn/string-content": "off",
|
||||
"unicorn/better-regex": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+52
-15
@@ -9,10 +9,57 @@
|
||||
|
||||
> Terminal string styling done right
|
||||
|
||||
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.npmjs.com/package/chalk?activeTab=dependents) [](https://www.npmjs.com/package/chalk) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo) 
|
||||
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.npmjs.com/package/chalk?activeTab=dependents) [](https://www.npmjs.com/package/chalk) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo)  [](https://repl.it/github/chalk/chalk)
|
||||
|
||||
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
|
||||
|
||||
<br>
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<p>
|
||||
<p>
|
||||
<sup>
|
||||
Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a> and <a href="https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15">Dev</a>
|
||||
</sup>
|
||||
</p>
|
||||
<sup>Special thanks to:</sup>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://standardresume.co/tech">
|
||||
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160"/>
|
||||
</a>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://retool.com/?utm_campaign=sindresorhus">
|
||||
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="230"/>
|
||||
</a>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=chalk&utm_source=github">
|
||||
<div>
|
||||
<img src="https://dashboard.doppler.com/imgs/logo-long.svg" width="240" alt="Doppler">
|
||||
</div>
|
||||
<b>All your environment variables, in one place</b>
|
||||
<div>
|
||||
<span>Stop struggling with scattered API keys, hacking together home-brewed tools,</span>
|
||||
<br>
|
||||
<span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
|
||||
</div>
|
||||
</a>
|
||||
<br>
|
||||
<a href="https://uibakery.io/?utm_source=chalk&utm_medium=sponsor&utm_campaign=github">
|
||||
<div>
|
||||
<img src="https://sindresorhus.com/assets/thanks/uibakery-logo.jpg" width="270" alt="UI Bakery">
|
||||
</div>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
|
||||
## Highlights
|
||||
|
||||
@@ -24,8 +71,7 @@
|
||||
- Doesn't extend `String.prototype`
|
||||
- Clean and focused
|
||||
- Actively maintained
|
||||
- [Used by ~46,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 1, 2019
|
||||
|
||||
- [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020
|
||||
|
||||
## Install
|
||||
|
||||
@@ -33,7 +79,6 @@
|
||||
$ npm install chalk
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
@@ -107,7 +152,6 @@ console.log(chalk.green('Hello %s'), name);
|
||||
//=> 'Hello Sindre'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### chalk.`<style>[.<style>...](string, [string...])`
|
||||
@@ -149,7 +193,6 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
|
||||
|
||||
`chalk.stderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `chalk.supportsColor` apply to this too. `chalk.stderr.supportsColor` is exposed for convenience.
|
||||
|
||||
|
||||
## Styles
|
||||
|
||||
### Modifiers
|
||||
@@ -202,10 +245,9 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
|
||||
- `bgCyanBright`
|
||||
- `bgWhiteBright`
|
||||
|
||||
|
||||
## Tagged template literal
|
||||
|
||||
Chalk can be used as a [tagged template literal](http://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
|
||||
Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
@@ -221,10 +263,11 @@ console.log(chalk`
|
||||
|
||||
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
|
||||
|
||||
Template styles are chained exactly like normal Chalk styles. The following two statements are equivalent:
|
||||
Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
|
||||
|
||||
```js
|
||||
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
|
||||
console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
|
||||
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
|
||||
```
|
||||
|
||||
@@ -232,7 +275,6 @@ Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain
|
||||
|
||||
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
|
||||
|
||||
|
||||
## 256 and Truecolor color support
|
||||
|
||||
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
|
||||
@@ -262,24 +304,20 @@ The following color models can be used:
|
||||
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
|
||||
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
||||
|
||||
|
||||
## Windows
|
||||
|
||||
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
||||
|
||||
|
||||
## Origin story
|
||||
|
||||
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
|
||||
|
||||
|
||||
## chalk for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
|
||||
@@ -297,7 +335,6 @@ The maintainers of chalk and thousands of other packages are working with Tideli
|
||||
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
||||
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
|
||||
+12
-16
@@ -6,6 +6,8 @@ const {
|
||||
stringEncaseCRLFWithFirstIndex
|
||||
} = require('./util');
|
||||
|
||||
const {isArray} = Array;
|
||||
|
||||
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
||||
const levelMapping = [
|
||||
'ansi',
|
||||
@@ -17,7 +19,7 @@ const levelMapping = [
|
||||
const styles = Object.create(null);
|
||||
|
||||
const applyOptions = (object, options = {}) => {
|
||||
if (options.level > 3 || options.level < 0) {
|
||||
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
||||
throw new Error('The `level` option should be an integer from 0 to 3');
|
||||
}
|
||||
|
||||
@@ -28,6 +30,7 @@ const applyOptions = (object, options = {}) => {
|
||||
|
||||
class ChalkClass {
|
||||
constructor(options) {
|
||||
// eslint-disable-next-line no-constructor-return
|
||||
return chalkFactory(options);
|
||||
}
|
||||
}
|
||||
@@ -134,14 +137,19 @@ const createStyler = (open, close, parent) => {
|
||||
|
||||
const createBuilder = (self, _styler, _isEmpty) => {
|
||||
const builder = (...arguments_) => {
|
||||
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
||||
// Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
|
||||
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
||||
}
|
||||
|
||||
// Single argument is hot path, implicit coercion is faster than anything
|
||||
// eslint-disable-next-line no-implicit-coercion
|
||||
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
||||
};
|
||||
|
||||
// `__proto__` is used because we must return a function, but there is
|
||||
// We alter the prototype because we must return a function, but there is
|
||||
// no way to create a function with a different prototype
|
||||
builder.__proto__ = proto; // eslint-disable-line no-proto
|
||||
Object.setPrototypeOf(builder, proto);
|
||||
|
||||
builder._generator = self;
|
||||
builder._styler = _styler;
|
||||
@@ -188,7 +196,7 @@ let template;
|
||||
const chalkTag = (chalk, ...strings) => {
|
||||
const [firstString] = strings;
|
||||
|
||||
if (!Array.isArray(firstString)) {
|
||||
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
||||
// If chalk() was called by itself or with a string,
|
||||
// return the string itself as a string.
|
||||
return strings.join(' ');
|
||||
@@ -218,16 +226,4 @@ chalk.supportsColor = stdoutColor;
|
||||
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
|
||||
chalk.stderr.supportsColor = stderrColor;
|
||||
|
||||
// For TypeScript
|
||||
chalk.Level = {
|
||||
None: 0,
|
||||
Basic: 1,
|
||||
Ansi256: 2,
|
||||
TrueColor: 3,
|
||||
0: 'None',
|
||||
1: 'Basic',
|
||||
2: 'Ansi256',
|
||||
3: 'TrueColor'
|
||||
};
|
||||
|
||||
module.exports = chalk;
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
||||
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
||||
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
||||
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi;
|
||||
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
||||
|
||||
const ESCAPES = new Map([
|
||||
['n', '\n'],
|
||||
@@ -126,8 +126,8 @@ module.exports = (chalk, temporary) => {
|
||||
chunks.push(chunk.join(''));
|
||||
|
||||
if (styles.length > 0) {
|
||||
const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
||||
throw new Error(errMsg);
|
||||
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
||||
throw new Error(errMessage);
|
||||
}
|
||||
|
||||
return chunks.join('');
|
||||
|
||||
+26
-27
@@ -1,62 +1,61 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"boxen@4.2.0",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"boxen@5.1.2",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "boxen@4.2.0",
|
||||
"_id": "boxen@4.2.0",
|
||||
"_from": "boxen@5.1.2",
|
||||
"_id": "boxen@5.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-eB4uT9RGzg2odpER62bBwSLvUeGC+WbRjjyyFhGsKnc8wp/m0+hQsMUvUe3H2V0D5vw0nBdO1hCJoZo5mKeuIQ==",
|
||||
"_integrity": "sha512-9gYgQKXx+1nP8mP7CzFyaUARhg7D3n1dF/FnErWmu9l6JvGpNUN278h0aSb+QjoiKSWG+iZ3uHrcqk0qrY9RQQ==",
|
||||
"_location": "/boxen",
|
||||
"_phantomChildren": {
|
||||
"@types/color-name": "1.1.1",
|
||||
"emoji-regex": "8.0.0"
|
||||
"supports-color": "7.2.0"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "boxen@4.2.0",
|
||||
"raw": "boxen@5.1.2",
|
||||
"name": "boxen",
|
||||
"escapedName": "boxen",
|
||||
"rawSpec": "4.2.0",
|
||||
"rawSpec": "5.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "4.2.0"
|
||||
"fetchSpec": "5.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@nuxt/cli"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/boxen/-/boxen-4.2.0.tgz",
|
||||
"_spec": "4.2.0",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/boxen/-/boxen-5.1.2.tgz",
|
||||
"_spec": "5.1.2",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/boxen/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-align": "^3.0.0",
|
||||
"camelcase": "^5.3.1",
|
||||
"chalk": "^3.0.0",
|
||||
"cli-boxes": "^2.2.0",
|
||||
"string-width": "^4.1.0",
|
||||
"term-size": "^2.1.0",
|
||||
"type-fest": "^0.8.1",
|
||||
"widest-line": "^3.1.0"
|
||||
"camelcase": "^6.2.0",
|
||||
"chalk": "^4.1.0",
|
||||
"cli-boxes": "^2.2.1",
|
||||
"string-width": "^4.2.2",
|
||||
"type-fest": "^0.20.2",
|
||||
"widest-line": "^3.1.0",
|
||||
"wrap-ansi": "^7.0.0"
|
||||
},
|
||||
"description": "Create boxes in the terminal",
|
||||
"devDependencies": {
|
||||
"ava": "^2.1.0",
|
||||
"nyc": "^14.1.1",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.25.3"
|
||||
"ava": "^2.4.0",
|
||||
"nyc": "^15.1.0",
|
||||
"tsd": "^0.14.0",
|
||||
"xo": "^0.36.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
"node": ">=10"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
@@ -85,5 +84,5 @@
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava && tsd"
|
||||
},
|
||||
"version": "4.2.0"
|
||||
"version": "5.1.2"
|
||||
}
|
||||
|
||||
+59
-2
@@ -1,4 +1,4 @@
|
||||
# boxen [](https://travis-ci.org/sindresorhus/boxen)
|
||||
# boxen
|
||||
|
||||
> Create boxes in the terminal
|
||||
|
||||
@@ -34,6 +34,13 @@ console.log(boxen('unicorn', {padding: 1, margin: 1, borderStyle: 'double'}));
|
||||
╚═════════════╝
|
||||
|
||||
*/
|
||||
|
||||
console.log(boxen('unicorns love rainbows', {title: 'magical', titleAlignment: 'center'}));
|
||||
/*
|
||||
┌────── magical ───────┐
|
||||
│unicorns love rainbows│
|
||||
└──────────────────────┘
|
||||
*/
|
||||
```
|
||||
|
||||
## API
|
||||
@@ -127,6 +134,56 @@ Default: `false`
|
||||
|
||||
Reduce opacity of the border.
|
||||
|
||||
##### title
|
||||
|
||||
Type: `string`
|
||||
|
||||
Display a title at the top of the box.
|
||||
If needed, the box will horizontally expand to fit the title.
|
||||
|
||||
Example:
|
||||
```js
|
||||
console.log(boxen('foo bar', {title: 'example'}));
|
||||
/*
|
||||
┌ example ┐
|
||||
│foo bar │
|
||||
└─────────┘
|
||||
*/
|
||||
```
|
||||
|
||||
##### titleAlignment
|
||||
|
||||
Type: `string`\
|
||||
Default: `'left'`
|
||||
|
||||
Align the title in the top bar.
|
||||
|
||||
Values:
|
||||
- `'left'`
|
||||
```js
|
||||
/*
|
||||
┌ example ──────┐
|
||||
│foo bar foo bar│
|
||||
└───────────────┘
|
||||
*/
|
||||
```
|
||||
- `'center'`
|
||||
```js
|
||||
/*
|
||||
┌─── example ───┐
|
||||
│foo bar foo bar│
|
||||
└───────────────┘
|
||||
*/
|
||||
```
|
||||
- `'right'`
|
||||
```js
|
||||
/*
|
||||
┌────── example ┐
|
||||
│foo bar foo bar│
|
||||
└───────────────┘
|
||||
*/
|
||||
```
|
||||
|
||||
##### padding
|
||||
|
||||
Type: `number | object`\
|
||||
@@ -160,7 +217,7 @@ Values: `'black'` `'red'` `'green'` `'yellow'` `'blue'` `'magenta'` `'cyan'` `'w
|
||||
|
||||
Color of the background.
|
||||
|
||||
##### align
|
||||
##### textAlignment
|
||||
|
||||
Type: `string`\
|
||||
Default: `'left'`\
|
||||
|
||||
Reference in New Issue
Block a user