Initial commit
This commit is contained in:
21
node/TestCli/node_modules/gradient-string/LICENSE
generated
vendored
Normal file
21
node/TestCli/node_modules/gradient-string/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Boris K
|
||||
|
||||
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.
|
||||
195
node/TestCli/node_modules/gradient-string/README.md
generated
vendored
Normal file
195
node/TestCli/node_modules/gradient-string/README.md
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
# gradient-string
|
||||
|
||||
[![Build Status][build-src]][build-href]
|
||||
[![Version][version-src]][version-href]
|
||||
[![Codecov][codecov-src]][codecov-href]
|
||||
[![Downloads][downloads-src]][downloads-href]
|
||||
[![XO code style][xo-src]][xo-href]
|
||||
[![Mentioned in Awesome Node.js][awesome-src]][awesome-href]
|
||||
|
||||
|
||||
> Beautiful color gradients in terminal output
|
||||
|
||||
[](http://bit.ly/gradient-string-large)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm i gradient-string
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
const gradient = require('gradient-string');
|
||||
|
||||
console.log(gradient('cyan', 'pink')('Hello world!'));
|
||||
```
|
||||
|
||||
### Initialize a gradient
|
||||
|
||||
```javascript
|
||||
// Using varargs
|
||||
let coolGradient = gradient('red', 'green', 'blue');
|
||||
|
||||
// Using array
|
||||
let coolGradient = gradient(['#FF0000', '#00FF00', '#0000FF']);
|
||||
```
|
||||
|
||||
The colors are parsed with TinyColor, [multiple formats are accepted](https://github.com/bgrins/TinyColor/blob/master/README.md#accepted-string-input).
|
||||
|
||||
```javascript
|
||||
let coolGradient = gradient([
|
||||
tinycolor('#FFBB65'), // tinycolor object
|
||||
{r: 0, g: 255, b: 0}, // RGB object
|
||||
{h: 240, s: 1, v: 1, a: 1}, // HSVa object
|
||||
'rgb(120, 120, 0)', // RGB CSS string
|
||||
'gold' // named color
|
||||
]);
|
||||
```
|
||||
|
||||
### Use a gradient
|
||||
|
||||
```javascript
|
||||
let coolString = coolGradient('This is a fancy string!');
|
||||
console.log(coolString);
|
||||
```
|
||||
|
||||
## Built-in gradients
|
||||
|
||||
### Usage
|
||||
|
||||
```javascript
|
||||
const gradient = require('gradient-string');
|
||||
|
||||
// Use the rainbow gradient
|
||||
console.log(gradient.rainbow('I love gradient-strings!'))
|
||||
```
|
||||
|
||||
### Available built-in gradients
|
||||
|
||||
[](http://bit.ly/2ufX07r)
|
||||
|
||||
## Multi line gradients
|
||||
|
||||
In some cases, you may want to apply the same horizontal gradient on each line of a long text (or a piece of ASCII art).
|
||||
|
||||
You can use the `multiline()` method of a gradient to ensure that the colors are vertically aligned.
|
||||
|
||||
```javascript
|
||||
const gradient = require('gradient-string');
|
||||
|
||||
// Use the same gradient on every line
|
||||
let duck = gradient('orange', 'yellow').multiline([
|
||||
" __",
|
||||
"<(o )___",
|
||||
" ( ._> /",
|
||||
" `---'",
|
||||
].join('\n'));
|
||||
console.log(duck);
|
||||
|
||||
// Works with aliases
|
||||
gradient.atlas.multiline('Multi line\nstring');
|
||||
|
||||
// Works with advanced options
|
||||
gradient('cyan', 'pink').multiline('Multi line\nstring', {interpolation: 'hsv'});
|
||||
```
|
||||
|
||||
|
||||
## Advanced gradients
|
||||
|
||||
There are also more advanced options for gradient customization, such as custom color stops, or choice of color interpolation
|
||||
|
||||
### Custom color stops
|
||||
|
||||
By default, the gradient color stops are distributed equidistantly.
|
||||
|
||||
You can specify the position of each color stop (between `0` and `1`), using the following syntax:
|
||||
|
||||
```javascript
|
||||
let coolGradient = gradient([
|
||||
{color: '#d8e0de', pos: 0},
|
||||
{color: '#255B53', pos: 0.8},
|
||||
{color: '#000000', pos: 1}
|
||||
]);
|
||||
```
|
||||
|
||||
### Color interpolation
|
||||
|
||||
When using a gradient, you can actually add a second parameter to choose how the colors will be generated.
|
||||
|
||||
Here is the full gradient API:
|
||||
|
||||
#### myGradient(text, [options])
|
||||
|
||||
##### text
|
||||
Type: `string`<br>
|
||||
String you want to color.
|
||||
|
||||
##### options
|
||||
Type: `Object`<br>
|
||||
|
||||
###### interpolation
|
||||
Type: `string`<br>
|
||||
The gradient can be generated using RGB or HSV interpolation. HSV usually produces brighter colors.
|
||||
`interpolation` can be set to `rgb` for RGB interpolation, or`hsv` for HSV interpolation.<br>
|
||||
Defaults to `rgb`. Case insentitive
|
||||
|
||||
###### hsvSpin
|
||||
Type: `string`<br>
|
||||
Used only in the case of HSV interpolation.<br>
|
||||
Because hue can be considered as a circle, there are two ways to go from a color to another color.<br>
|
||||
`hsvSpin` can be either `short` or `long`, depending on if you want to take the shortest or the longest way between two colors.<br>
|
||||
Defaults to `short`. Case insensitive
|
||||
|
||||
#### Example
|
||||
##### Code
|
||||
```javascript
|
||||
const redToGreen = gradient('red', 'green');
|
||||
const str = '■'.repeat(48);
|
||||
|
||||
// Standard RGB gradient
|
||||
console.log(redToGreen(str));
|
||||
|
||||
// Short HSV gradient: red -> yellow -> green
|
||||
console.log(redToGreen(str, {interpolation: 'hsv'}));
|
||||
|
||||
// Long HSV gradient: red -> magenta -> blue -> cyan -> green
|
||||
console.log(redToGreen(str, {interpolation: 'hsv', hsvSpin: 'long'}));
|
||||
```
|
||||
##### Result
|
||||

|
||||
|
||||
## Typescript
|
||||
|
||||
Typescript definitions of gradient-string are available on [DefinitelyTyped](https://www.npmjs.com/package/@types/gradient-string)
|
||||
|
||||
```sh
|
||||
npm i @types/gradient-string
|
||||
```
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
- [tinygradient](https://github.com/mistic100/tinygradient) - Generate gradients
|
||||
- [chalk](https://github.com/chalk/chalk) - Output colored text to terminal
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Boris K](https://github.com/bokub)
|
||||
|
||||
[build-src]: https://flat.badgen.net/travis/bokub/gradient-string
|
||||
[version-src]: https://runkit.io/bokub/npm-version/branches/master/gradient-string?style=flat
|
||||
[codecov-src]: https://flat.badgen.net/codecov/c/github/bokub/gradient-string
|
||||
[downloads-src]: https://flat.badgen.net/npm/dm/gradient-string?color=FF9800
|
||||
[xo-src]: https://flat.badgen.net/badge/code%20style/XO/5ed9c7
|
||||
[awesome-src]: https://awesome.re/mentioned-badge-flat.svg
|
||||
|
||||
[build-href]: https://travis-ci.org/bokub/gradient-string
|
||||
[version-href]: https://www.npmjs.com/package/gradient-string
|
||||
[codecov-href]: https://codecov.io/gh/bokub/gradient-string
|
||||
[downloads-href]: https://www.npmjs.com/package/gradient-string
|
||||
[xo-href]: https://github.com/sindresorhus/xo
|
||||
[awesome-href]: https://github.com/sindresorhus/awesome-nodejs
|
||||
82
node/TestCli/node_modules/gradient-string/index.js
generated
vendored
Normal file
82
node/TestCli/node_modules/gradient-string/index.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
'use strict';
|
||||
|
||||
const chalk = require('chalk');
|
||||
const tinygradient = require('tinygradient');
|
||||
|
||||
const forbiddenChars = /\s/g;
|
||||
|
||||
function InitGradient(...args) {
|
||||
const grad = tinygradient.apply(this, args);
|
||||
const ret = (str, opts) => applyGradient(str ? str.toString() : '', grad, opts);
|
||||
ret.multiline = (str, opts) => multilineGradient(str ? str.toString() : '', grad, opts);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const getColors = (gradient, options, count) => options.interpolation.toLowerCase() === 'hsv' ?
|
||||
gradient.hsv(count, options.hsvSpin.toLowerCase()) : gradient.rgb(count);
|
||||
|
||||
function applyGradient(str, gradient, opts) {
|
||||
const options = validateOptions(opts);
|
||||
const colorsCount = Math.max(str.replace(forbiddenChars, '').length, gradient.stops.length);
|
||||
const colors = getColors(gradient, options, colorsCount);
|
||||
let result = '';
|
||||
for (const s of str) {
|
||||
result += s.match(forbiddenChars) ? s : chalk.hex(colors.shift().toHex())(s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function multilineGradient(str, gradient, opts) {
|
||||
const options = validateOptions(opts);
|
||||
const lines = str.split('\n');
|
||||
const maxLength = Math.max.apply(null, lines.map(l => l.length).concat([gradient.stops.length]));
|
||||
const colors = getColors(gradient, options, maxLength);
|
||||
const results = [];
|
||||
for (const line of lines) {
|
||||
const lineColors = colors.slice(0);
|
||||
let lineResult = '';
|
||||
for (const l of line) {
|
||||
lineResult += chalk.hex(lineColors.shift().toHex())(l);
|
||||
}
|
||||
results.push(lineResult);
|
||||
}
|
||||
return results.join('\n');
|
||||
}
|
||||
|
||||
function validateOptions(opts) {
|
||||
const options = {interpolation: 'rgb', hsvSpin: 'short', ...opts};
|
||||
if (opts !== undefined && typeof opts !== 'object') {
|
||||
throw new TypeError(`Expected \`options\` to be an \`object\`, got \`${typeof opts}\``);
|
||||
}
|
||||
|
||||
if (typeof options.interpolation !== 'string') {
|
||||
throw new TypeError(`Expected \`options.interpolation\` to be a \`string\`, got \`${typeof options.interpolation}\``);
|
||||
}
|
||||
|
||||
if (options.interpolation.toLowerCase() === 'hsv' && typeof options.hsvSpin !== 'string') {
|
||||
throw new TypeError(`Expected \`options.hsvSpin\` to be a \`string\`, got \`${typeof options.hsvSpin}\``);
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
const aliases = {
|
||||
atlas: {colors: ['#feac5e', '#c779d0', '#4bc0c8'], options: {}},
|
||||
cristal: {colors: ['#bdfff3', '#4ac29a'], options: {}},
|
||||
teen: {colors: ['#77a1d3', '#79cbca', '#e684ae'], options: {}},
|
||||
mind: {colors: ['#473b7b', '#3584a7', '#30d2be'], options: {}},
|
||||
morning: {colors: ['#ff5f6d', '#ffc371'], options: {interpolation: 'hsv'}},
|
||||
vice: {colors: ['#5ee7df', '#b490ca'], options: {interpolation: 'hsv'}},
|
||||
passion: {colors: ['#f43b47', '#453a94'], options: {}},
|
||||
fruit: {colors: ['#ff4e50', '#f9d423'], options: {}},
|
||||
instagram: {colors: ['#833ab4', '#fd1d1d', '#fcb045'], options: {}},
|
||||
retro: {colors: ['#3f51b1', '#5a55ae', '#7b5fac', '#8f6aae', '#a86aa4', '#cc6b8e', '#f18271', '#f3a469', '#f7c978'], options: {}},
|
||||
summer: {colors: ['#fdbb2d', '#22c1c3'], options: {}},
|
||||
rainbow: {colors: ['#ff0000', '#ff0100'], options: {interpolation: 'hsv', hsvSpin: 'long'}},
|
||||
pastel: {colors: ['#74ebd5', '#74ecd5'], options: {interpolation: 'hsv', hsvSpin: 'long'}}
|
||||
};
|
||||
|
||||
module.exports = InitGradient;
|
||||
for (const a in aliases) { // eslint-disable-line guard-for-in
|
||||
module.exports[a] = str => new InitGradient(aliases[a].colors)(str, aliases[a].options);
|
||||
module.exports[a].multiline = str => new InitGradient(aliases[a].colors).multiline(str, aliases[a].options);
|
||||
}
|
||||
58
node/TestCli/node_modules/gradient-string/package.json
generated
vendored
Normal file
58
node/TestCli/node_modules/gradient-string/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "gradient-string",
|
||||
"description": "Beautiful color gradients in terminal output",
|
||||
"version": "2.0.0",
|
||||
"author": "Boris K",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"built-in": "node examples/built-in.js",
|
||||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
||||
"demo": "node examples/demo.js",
|
||||
"fix": "xo --fix",
|
||||
"test": "xo && nyc cross-env FORCE_COLOR=1 ava"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
"tinygradient": "^1.1.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"codecov": "^3.8.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"nyc": "^15.1.0",
|
||||
"xo": "0.23.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"repository": "bokub/gradient-string",
|
||||
"homepage": "https://github.com/bokub/gradient-string",
|
||||
"bugs": "https://github.com/bokub/gradient-string/issues",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"color",
|
||||
"colors",
|
||||
"colour",
|
||||
"command-line",
|
||||
"console",
|
||||
"formatting",
|
||||
"gradient",
|
||||
"gradients",
|
||||
"log",
|
||||
"logging",
|
||||
"shell",
|
||||
"string",
|
||||
"style",
|
||||
"styles",
|
||||
"terminal"
|
||||
],
|
||||
"ava": {
|
||||
"require": [
|
||||
"esm"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user