Skip to content

Commit

Permalink
removed colors dependency #116
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiDittrich committed Jan 9, 2022
1 parent 7f1b7f0 commit 1f0c40e
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 25 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
@@ -1,5 +1,11 @@
## Branch 3.x ##

### 3.10.0 ###

* Changed: foreground color of `preset.shades-grey` is set directly by ANSI codes
* Changed: example snippets are using `ansi-colors` library
* Bugfix: removed `colors` dependency due to some issues with the maintainer... see [Zalgo bomb](https://github.com/Marak/colors.js/issues/285#issuecomment-1008212640)

### 3.9.1 ###

* Bugfix: duration calculation doesn't work for bar restart scenarios - thanks to [autlaw on GitHub](https://github.com/npkgz/cli-progress/pull/101)
Expand Down
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -65,7 +65,9 @@ Single Bar Mode

```js
const cliProgress = require('cli-progress');
const colors = require('colors');

// note: you have to install this dependency manually since it's not required by cli-progress
const colors = require('ansi-colors');

// create new progress bar
const b1 = new cliProgress.SingleBar({
Expand Down Expand Up @@ -394,7 +396,7 @@ bar.stop();
**File** `myPreset.js`

```js
const colors = require('colors');
const colors = require('ansi-colors');

module.exports = {
format: colors.red(' {bar}') + ' {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit',
Expand Down
8 changes: 8 additions & 0 deletions examples/README.md
@@ -0,0 +1,8 @@
cli-progress examples
=================================

Note: some of the examples are using the `ansi-colors` library for styling - since this lib is not required for `cli-progress` itself you have to install it manually!

```bash
yarn install ansi-colors
```
8 changes: 4 additions & 4 deletions examples/example-align.js
@@ -1,13 +1,13 @@
var _progress = require('../cli-progress');
var _colors = require('colors');
const _progress = require('../cli-progress');
const _colors = require('ansi-colors');

// helper function to display preset
function showPreset(name, pos){
console.log(_colors.magenta('Preset: ' + name));

// create a new progress bar with preset
var bar = new _progress.Bar({
align: pos
const bar = new _progress.Bar({
align: pos
}, _progress.Presets[name] || _progress.Presets.legacy);
bar.start(200, 0);

Expand Down
2 changes: 1 addition & 1 deletion examples/example-formatter.js
@@ -1,5 +1,5 @@
const _progress = require('../cli-progress');
const _colors = require('colors');
const _colors = require('ansi-colors');

function myFormatter(options, params, payload){

Expand Down
6 changes: 3 additions & 3 deletions examples/example-presets.js
@@ -1,12 +1,12 @@
var _progress = require('../cli-progress');
var _colors = require('colors');
const _progress = require('../cli-progress');
const _colors = require('ansi-colors');

// helper function to display preset
function showPreset(name){
console.log(_colors.magenta('Preset: ' + name));

// create a new progress bar with preset
var bar = new _progress.Bar({}, _progress.Presets[name] || _progress.Presets.legacy);
const bar = new _progress.Bar({}, _progress.Presets[name] || _progress.Presets.legacy);
bar.start(200, 0);

// random value 1..200
Expand Down
12 changes: 6 additions & 6 deletions examples/example-visual.js
@@ -1,10 +1,10 @@
const _progress = require('../cli-progress');
const _colors = require('colors');
const _colors = require('ansi-colors');

function Example5(){
console.log('');
// create new progress bar
var b1 = new _progress.Bar({
const b1 = new _progress.Bar({
format: 'CLI Progress |' + _colors.cyan('{bar}') + '| {percentage}% || {value}/{total} Chunks || Speed: {speed}',
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
Expand All @@ -17,18 +17,18 @@ function Example5(){
});

// the bar value - will be linear incremented
var value = 0;
let value = 0;

var speedData = [];
const speedData = [];

// 20ms update rate
var timer = setInterval(function(){
const timer = setInterval(function(){
// increment value
value++;

// example speed data
speedData.push(Math.random()*2+5);
var currentSpeedData = speedData.splice(-10);
const currentSpeedData = speedData.splice(-10);

// update the bar value
b1.update(value, {
Expand Down
3 changes: 1 addition & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "cli-progress",
"version": "3.9.1",
"version": "3.10.0",
"description": "easy to use progress-bar for command-line/terminal applications",
"keywords": [
"cli",
Expand Down Expand Up @@ -35,7 +35,6 @@
"author": "Andi Dittrich (https://andidittrich.com)",
"license": "MIT",
"dependencies": {
"colors": "^1.1.2",
"string-width": "^4.2.0"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions presets/shades-grey.js
@@ -1,8 +1,7 @@
const _colors = require('colors');

// cli-progress legacy style as of 1.x
module.exports = {
format: _colors.grey(' {bar}') + ' {percentage}% | ETA: {eta}s | {value}/{total}',
format: ' \u001b[90m{bar}\u001b[0m {percentage}% | ETA: {eta}s | {value}/{total}',
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591'
};
10 changes: 5 additions & 5 deletions yarn.lock
Expand Up @@ -48,6 +48,11 @@ ansi-colors@3.2.3:
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813"
integrity sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==

ansi-colors@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==

ansi-escapes@^4.2.1:
version "4.3.2"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e"
Expand Down Expand Up @@ -234,11 +239,6 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

colors@^1.1.2:
version "1.4.0"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78"
integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==

concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
Expand Down

0 comments on commit 1f0c40e

Please sign in to comment.