Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys authored and ruyadorno committed Apr 26, 2022
1 parent 13299ee commit 0f2da5d
Show file tree
Hide file tree
Showing 29 changed files with 227 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Original Library

Additional Functionality
- Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
- Copyright (c) DABH (https://github.com/DABH)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ console.log('Background color attack!'.black.bgWhite);
console.log('Use random styles on everything!'.random);
console.log('America, Heck Yeah!'.america);

// eslint-disable-next-line max-len
console.log('Blindingly '.brightCyan + 'bright? '.brightRed + 'Why '.brightYellow + 'not?!'.brightGreen);

console.log('Setting themes is useful');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ console.log(colors.black.bgWhite('Background color attack!'));
console.log(colors.random('Use random styles on everything!'));
console.log(colors.america('America, Heck Yeah!'));

// eslint-disable-next-line max-len
console.log(colors.brightCyan('Blindingly ') + colors.brightRed('bright? ') + colors.brightYellow('Why ') + colors.brightGreen('not?!'));

console.log('Setting themes is useful');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Type definitions for Colors.js 1.2
// Type definitions for @colors/colors 1.4+
// Project: https://github.com/Marak/colors.js
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Staffan Eketorp <https://github.com/staeke>
// Definitions: https://github.com/Marak/colors.js
// Definitions: https://github.com/DABH/colors.js

export interface Color {
(text: string): string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var stylize = colors.stylize = function stylize(str, style) {
var styleMap = ansiStyles[style];

// Stylize should work for non-ANSI styles, too
if(!styleMap && style in colors){
if (!styleMap && style in colors) {
// Style maps like trap operate as functions on strings;
// they don't have properties like open or close.
return colors[style](str);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"name": "colors",
"name": "@colors/colors",
"description": "get colors in your node.js console",
"version": "1.4.0",
"author": "Marak Squires",
"version": "1.5.0",
"author": "DABH",
"contributors": [
{
"name": "DABH",
"url": "https://github.com/DABH"
}
],
"homepage": "https://github.com/Marak/colors.js",
"bugs": "https://github.com/Marak/colors.js/issues",
"homepage": "https://github.com/DABH/colors.js",
"bugs": "https://github.com/DABH/colors.js/issues",
"keywords": [
"ansi",
"terminal",
"colors"
],
"repository": {
"type": "git",
"url": "http://github.com/Marak/colors.js.git"
"url": "http://github.com/DABH/colors.js.git"
},
"license": "MIT",
"scripts": {
"lint": "eslint . --fix",
"test": "node tests/basic-test.js && node tests/safe-test.js"
"test": "export FORCE_COLOR=1 && node tests/basic-test.js && node tests/safe-test.js"
},
"engines": {
"node": ">=0.1.90"
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions node_modules/cli-table3/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ declare namespace CliTable3 {
rowAligns: VerticalAlignment[];
head: string[];
wordWrap: boolean;
wrapOnWordBoundary: boolean;
}

interface TableInstanceOptions extends TableOptions {
Expand Down
8 changes: 4 additions & 4 deletions node_modules/cli-table3/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cli-table3",
"version": "0.6.1",
"version": "0.6.2",
"description": "Pretty unicode tables for the command line. Based on the original cli-table.",
"main": "index.js",
"types": "index.d.ts",
Expand All @@ -16,8 +16,8 @@
"string-width": "^4.2.0"
},
"devDependencies": {
"ansi-256-colors": "^1.1.0",
"cli-table": "^0.3.1",
"eslint": "^6.0.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "^3.0.0",
"jest": "^25.2.4",
Expand All @@ -26,7 +26,7 @@
"prettier": "2.3.2"
},
"optionalDependencies": {
"colors": "1.4.0"
"@colors/colors": "1.5.0"
},
"scripts": {
"changelog": "lerna-changelog",
Expand Down Expand Up @@ -75,7 +75,7 @@
{
"displayName": "test",
"testMatch": [
"<rootDir>/test/*.js"
"<rootDir>/test/**/*.js"
]
},
{
Expand Down
63 changes: 49 additions & 14 deletions node_modules/cli-table3/src/cell.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { info, debug } = require('./debug');
const utils = require('./utils');

class Cell {
Expand Down Expand Up @@ -30,12 +31,19 @@ class Cell {
if (['boolean', 'number', 'string'].indexOf(typeof content) !== -1) {
this.content = String(content);
} else if (!content) {
this.content = '';
this.content = this.options.href || '';
} else {
throw new Error('Content needs to be a primitive, got: ' + typeof content);
}
this.colSpan = options.colSpan || 1;
this.rowSpan = options.rowSpan || 1;
if (this.options.href) {
Object.defineProperty(this, 'href', {
get() {
return this.options.href;
},
});
}
}

mergeTableOptions(tableOptions, cells) {
Expand All @@ -57,23 +65,35 @@ class Cell {
this.head = style.head || tableStyle.head;
this.border = style.border || tableStyle.border;

let fixedWidth = tableOptions.colWidths[this.x];
if (tableOptions.wordWrap && fixedWidth) {
fixedWidth -= this.paddingLeft + this.paddingRight;
this.fixedWidth = tableOptions.colWidths[this.x];
this.lines = this.computeLines(tableOptions);

this.desiredWidth = utils.strlen(this.content) + this.paddingLeft + this.paddingRight;
this.desiredHeight = this.lines.length;
}

computeLines(tableOptions) {
if (this.fixedWidth && (tableOptions.wordWrap || tableOptions.textWrap)) {
this.fixedWidth -= this.paddingLeft + this.paddingRight;
if (this.colSpan) {
let i = 1;
while (i < this.colSpan) {
fixedWidth += tableOptions.colWidths[this.x + i];
this.fixedWidth += tableOptions.colWidths[this.x + i];
i++;
}
}
this.lines = utils.colorizeLines(utils.wordWrap(fixedWidth, this.content));
} else {
this.lines = utils.colorizeLines(this.content.split('\n'));
const { wrapOnWordBoundary = true } = tableOptions;
return this.wrapLines(utils.wordWrap(this.fixedWidth, this.content, wrapOnWordBoundary));
}
return this.wrapLines(this.content.split('\n'));
}

this.desiredWidth = utils.strlen(this.content) + this.paddingLeft + this.paddingRight;
this.desiredHeight = this.lines.length;
wrapLines(computedLines) {
const lines = utils.colorizeLines(computedLines);
if (this.href) {
return lines.map((line) => utils.hyperlink(this.href, line));
}
return lines;
}

/**
Expand Down Expand Up @@ -110,6 +130,12 @@ class Cell {
draw(lineNum, spanningCell) {
if (lineNum == 'top') return this.drawTop(this.drawRight);
if (lineNum == 'bottom') return this.drawBottom(this.drawRight);
let content = utils.truncate(this.content, 10, this.truncate);
if (!lineNum) {
info(`${this.y}-${this.x}: ${this.rowSpan - lineNum}x${this.colSpan} Cell ${content}`);
} else {
// debug(`${lineNum}-${this.x}: 1x${this.colSpan} RowSpanCell ${content}`);
}
let padLen = Math.max(this.height - this.lines.length, 0);
let padTop;
switch (this.vAlign) {
Expand Down Expand Up @@ -186,7 +212,7 @@ class Cell {
wrapWithStyleColors(styleProperty, content) {
if (this[styleProperty] && this[styleProperty].length) {
try {
let colors = require('colors/safe');
let colors = require('@colors/colors/safe');
for (let i = this[styleProperty].length - 1; i >= 0; i--) {
colors = colors[this[styleProperty][i]];
}
Expand Down Expand Up @@ -285,7 +311,10 @@ class ColSpanCell {
*/
constructor() {}

draw() {
draw(lineNum) {
if (typeof lineNum === 'number') {
debug(`${this.y}-${this.x}: 1x1 ColSpanCell`);
}
return '';
}

Expand Down Expand Up @@ -319,21 +348,26 @@ class RowSpanCell {
if (lineNum == 'bottom') {
return this.originalCell.draw('bottom');
}
debug(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`);
return this.originalCell.draw(this.offset + 1 + lineNum);
}

mergeTableOptions() {}
}

function firstDefined(...args) {
return args.filter((v) => v !== undefined && v !== null).shift();
}

// HELPER FUNCTIONS
function setOption(objA, objB, nameB, targetObj) {
let nameA = nameB.split('-');
if (nameA.length > 1) {
nameA[1] = nameA[1].charAt(0).toUpperCase() + nameA[1].substr(1);
nameA = nameA.join('');
targetObj[nameA] = objA[nameA] || objA[nameB] || objB[nameA] || objB[nameB];
targetObj[nameA] = firstDefined(objA[nameA], objA[nameB], objB[nameA], objB[nameB]);
} else {
targetObj[nameB] = objA[nameB] || objB[nameB];
targetObj[nameB] = firstDefined(objA[nameB], objB[nameB]);
}
}

Expand Down Expand Up @@ -366,6 +400,7 @@ let CHAR_NAMES = [
'right-mid',
'middle',
];

module.exports = Cell;
module.exports.ColSpanCell = ColSpanCell;
module.exports.RowSpanCell = RowSpanCell;
28 changes: 28 additions & 0 deletions node_modules/cli-table3/src/debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
let messages = [];
let level = 0;

const debug = (msg, min) => {
if (level >= min) {
messages.push(msg);
}
};

debug.WARN = 1;
debug.INFO = 2;
debug.DEBUG = 3;

debug.reset = () => {
messages = [];
};

debug.setDebugLevel = (v) => {
level = v;
};

debug.warn = (msg) => debug(msg, debug.WARN);
debug.info = (msg) => debug(msg, debug.INFO);
debug.debug = (msg) => debug(msg, debug.DEBUG);

debug.debugMessages = () => messages;

module.exports = debug;
Loading

0 comments on commit 0f2da5d

Please sign in to comment.