feat: ✨ Created a mini nodeJS server with NewMan for testing without PostMan GUI.
This will mimic a run in a CD/CI environment or docker container.
This commit is contained in:
169
node_modules/cli-progress/CHANGES.md
generated
vendored
Normal file
169
node_modules/cli-progress/CHANGES.md
generated
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
## Branch 3.x ##
|
||||
|
||||
### 3.9.0 ###
|
||||
|
||||
* Added: exported standard formatter and format helper
|
||||
* Added: example howto use multibars in synchronous context
|
||||
* Changed: upper eta display limit to `1e7` (115days) #92
|
||||
|
||||
### 3.8.2 ###
|
||||
|
||||
* Bugfix: bar duration not stopped until all bars have finished - thanks to [omjadas on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/71)
|
||||
|
||||
### 3.8.1 ###
|
||||
|
||||
* Bugfix: percentage calculation used `Math.round` which caused incorrect values for edge cases - thanks to [OxCom on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/70)
|
||||
|
||||
### 3.8.0 ###
|
||||
|
||||
* Changed: allow to pass payload as first argument to `increment()` with implicit delta of 1 - thanks to [ecdeveloper on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/67)
|
||||
* Changed: allow to pass payload as first argument to `update()` without updating bar value
|
||||
* Bugfix: `formatTime` option ignored due to type - thanks to [omjadas on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/68)
|
||||
|
||||
### 3.7.0 ###
|
||||
|
||||
* Added: asynchronous eta update for long running processes (optional) - feature [requested on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/65)
|
||||
* Added: method to trigger eta calculation without progress update
|
||||
|
||||
### 3.6.1 ###
|
||||
|
||||
* Bugfix: bar initialization overrides options within all instances - thanks to [BigBrainAFK on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/64)
|
||||
|
||||
### 3.6.0 ###
|
||||
|
||||
* Added: support for custom time-format function
|
||||
* Added: support for custom bar-format function
|
||||
* Added: support for custom value-format function
|
||||
* Added: auto-padding option to enforce fixed size of values - feature [requested on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/60)
|
||||
* Added: `barGlue` option to insert ascii escape sequences (e.g. for colorization) between the bar complete/incomplete elements - feature [requested on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/53)
|
||||
* Bugfix: `eta` value can be negative for multibars in case the bar is alredy completed
|
||||
|
||||
### 3.5.0 ###
|
||||
|
||||
* Added: support for events via [EventEmitter](https://nodejs.org/api/events.html) - feature [requested on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/58)
|
||||
|
||||
### 3.4.0 ###
|
||||
|
||||
* Added: testsuites based on mocha - thanks to [on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/49)
|
||||
* Added: automatic tests via [Travis CI](https://travis-ci.org/)
|
||||
* Bugfix: Fixing issues with falsy values in format which causes remdering artifacts - thanks to [on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/49)
|
||||
* Bugfix: documentation of the `stream` options was wrong - thanks to [ehmicky on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/51)
|
||||
* Changed: updated examples/syntax of `README.md` - thanks to [justsml on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/50)
|
||||
|
||||
### 3.3.1 ###
|
||||
|
||||
* Bugifx: synchronous update may cause unexpected behaviour on multibars - limited to single bars
|
||||
* Changed: renamed internal eta `push()` method to `update()`
|
||||
* Changed: moved internal eta calculation call into `update()`
|
||||
|
||||
### 3.3.0 ###
|
||||
|
||||
* Added: option to pass custom formatters as callback via `options.format`
|
||||
* Changed: replaced static placeholder code with generic regex (performance enhancement)
|
||||
|
||||
### 3.2.0 ###
|
||||
|
||||
* Added: `emptyOnZero` option to display total:0 bars as empty, not full - thanks to [nickcmaynard on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/42)
|
||||
* Bugfix: removed cursor save/restore calls for multibars - clearOnComplete might not work on all environments - thanks to [sayem314 onGitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/40)
|
||||
|
||||
### 3.1.0 ###
|
||||
|
||||
* Added: notty support (interval/schedule based output) - feature requested [on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/25)
|
||||
* Added: `stopOnComplete` support within `MultiBar` - thanks to [Nox-404 on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/35)
|
||||
* Changed: initial throttel time of `MultiBar` is controlled by `fps` option instead of static `500ms` value
|
||||
* Bugfix: provided option didn't take precedence over the preset as in v2 - thanks to [AxelTerizaki on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/37) #37
|
||||
|
||||
### 3.0.0 ###
|
||||
|
||||
* Added: multi-progressbar support - feature requested [on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/26)
|
||||
* Added: option `synchronousUpdate` to control the synchronized redraw during `update()` call (default=`true`)
|
||||
* Changed: project split into multiple classes
|
||||
* Changed: default cli progress output is written to `stdout` instead of `stderr`
|
||||
|
||||
## Branch 2.x ##
|
||||
|
||||
### 2.1.1 ###
|
||||
|
||||
* Bugifx: preset object got altered by options - thanks to [rvalitov on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/27) #27
|
||||
|
||||
### 2.1.0 ###
|
||||
|
||||
* Added: `align` option to change the position of the progress bar (left, center, right) - thanks to [sidneys on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/22) #22
|
||||
* Changed: ETA value of type `Infinity` is displayed as **INF**, `NaN` as **NULL** - feature requested by [AxelTerizaki on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/21) #21
|
||||
* Changed: Limited the maximum ETA value to `100000s` (**INF** is displayed in this case)
|
||||
* Changed: ETA calculation moved to own scope
|
||||
* Bugfix: example `example-notty.php` was broken
|
||||
|
||||
### 2.0.0 ###
|
||||
|
||||
Upgrade is possible without any code modifications! requires **node.js 4**
|
||||
|
||||
* Added: option `linewrap` to disable terminal line wrapping (default)
|
||||
* Changed: requires **node.js >= 4**
|
||||
* Changed: Native ES2015 class syntax
|
||||
* Changed: renamed application entry file to `cli-progress.js`
|
||||
* Changed: low-level terminal interactions are encapsulated within `Terminal` class
|
||||
* Changed: terminal/cursor settings are restored after progress bar stopped
|
||||
* Bugfix: used hex ascii escape sequences instaed of octals to avoid javascript errors in recent nodejs version
|
||||
* Bugfix: disabled line wrapping by default to avoid multiple line breaks on small terminals (cut on the right) - reported by [puppeteer701 on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/20) #20
|
||||
|
||||
## Branch 1.x ##
|
||||
|
||||
### 1.8.0 ###
|
||||
* Added: method `setTotal()` to manipulate the total value within running progress-bar - feature requested by [ReggaePanda on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/19) #19
|
||||
* Changed: moved example file to `examples/` directory
|
||||
|
||||
### 1.7.0 ###
|
||||
* Added: payload argument to `increment()` - feature requested by [dsego on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/18) #18
|
||||
|
||||
### 1.6.1 ###
|
||||
* Bugfix: `roundTo` parameter was not set for `elapsedTime` calculation which caused raw float values within formatted time strings - thanks to [rekinyz on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/16) #16
|
||||
|
||||
### 1.6.0 ###
|
||||
* Added: Additional payload data which can be used as **custom-tokens** within the bar - thanks to [tobiasps on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/15) #15
|
||||
|
||||
### 1.5.1 ###
|
||||
* Bugfix: Progressbar cannot be initialized to 0% - thanks to [erikkallen on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/14) #13
|
||||
* Bugfix: ETA was **NULL** in case the progress bar is initialized with (0/0)
|
||||
|
||||
### 1.5.0 ###
|
||||
* Added: **0** values for total/progress initialization are allowed - feature requested by [jfmmm on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/11) #11
|
||||
|
||||
### 1.4.0 ###
|
||||
* Added: **Preset/Theme support**. Different bar-styles can be loaded from internal library (in addition to full customization)
|
||||
* Added: Dependency **colors** for colorized progress bars
|
||||
* Added: Preset `legacy`
|
||||
* Added: Preset `shades-classic`
|
||||
* Added: Preset `shades-grey`
|
||||
* Added: Preset `rect`
|
||||
|
||||
### 1.3.1 ###
|
||||
* Added: `example-notty` to test the behaviour of progress bar in non-interactive environments (input streams closed)
|
||||
* Bugfix: `update()` throws an error in **non-tty** environments - reported by [Ognian on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/9) #9
|
||||
|
||||
### 1.3.0 ###
|
||||
* Added: `stopOnComplete` option to automatically call `stop()` when the value reaches the total - thanks to [lennym on GitHub](https://github.com/lennym) #7
|
||||
|
||||
### 1.2.0 ###
|
||||
* Added: `increment()` method to increase the current progress relatively - thanks to [lennym on GitHub](https://github.com/lennym) #6
|
||||
* Added: ETA time formatting options (mm:ss, hh:mm, ss) - thanks to [lennym on GitHub](https://github.com/lennym) #5
|
||||
* Improvement: More accurate ETA calculation using linear estimation of last N values - thanks to [lennym on GitHub](https://github.com/lennym) #4
|
||||
* Bugfix: FPS calculation error which caused performance issues - thanks to [lennym on GitHub](https://github.com/lennym) #7
|
||||
|
||||
### 1.1.2 ###
|
||||
* Bugfix: stdout.cursorTo/stdout.clearLine is not a function; replaced by `readline` - thanks to [remcoder on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/2)
|
||||
|
||||
### 1.1.1 ###
|
||||
* Bugfix: Hide cursor options was enabled by default
|
||||
|
||||
### 1.1.0 ###
|
||||
* Added: Support for synchronous operations (interval has been replaced by timeout and throttle time) - feature requested [GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/1)
|
||||
* Added: Synchronous Operation Example `example-synchronous.js`
|
||||
* Added: Option to hide the cursor `options.hideCursor` - default set to false
|
||||
* Changed: Improved ETA calculation
|
||||
|
||||
### 1.0.1 ###
|
||||
* Bugfix: the bar-size is limited to `options.barsize` - in some (numerical) situations it can be too long (n+1)
|
||||
|
||||
### 1.0.0 ###
|
||||
* Initial public release
|
24
node_modules/cli-progress/LICENSE.md
generated
vendored
Normal file
24
node_modules/cli-progress/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
The MIT License (X11 License)
|
||||
|
||||
Copyright (c) 2015-2020 Andi Dittrich
|
||||
|
||||
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.
|
446
node_modules/cli-progress/README.md
generated
vendored
Normal file
446
node_modules/cli-progress/README.md
generated
vendored
Normal file
@@ -0,0 +1,446 @@
|
||||
[](https://travis-ci.org/AndiDittrich/Node.CLI-Progress)
|
||||
|
||||
[Single Bar](#single-bar-mode) | [Multi Bar](#multi-bar-mode) | [Options](#options-1) | [Examples](examples/) | [Presets](presets/) | [Events](docs/events.md)
|
||||
|
||||
CLI-Progress
|
||||
============
|
||||
easy to use progress-bar for command-line/terminal applications
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Install
|
||||
--------
|
||||
|
||||
```bash
|
||||
$ yarn add cli-progress
|
||||
$ npm install cli-progress --save
|
||||
```
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* **Simple**, **Robust** and **Easy** to use
|
||||
* Full customizable output format (constious placeholders are available)
|
||||
* Single progressbar mode
|
||||
* Multi progessbar mode
|
||||
* Custom Bar Characters
|
||||
* FPS limiter
|
||||
* ETA calculation based on elapsed time
|
||||
* Custom Tokens to display additional data (payload) within the bar
|
||||
* TTY and NOTTY mode
|
||||
* No callbacks required - designed as pure, external controlled UI widget
|
||||
* Works in Asynchronous and Synchronous tasks
|
||||
* Preset/Theme support
|
||||
* Custom bar formatters (via callback)
|
||||
|
||||
Usage
|
||||
------------
|
||||
|
||||
Multiple examples are available e.g. [example.js](https://github.com/AndiDittrich/Node.CLI-Progress/blob/master/examples/example.js) - just try it `$ node example.js`
|
||||
|
||||
```js
|
||||
const cliProgress = require('cli-progress');
|
||||
|
||||
// create a new progress bar instance and use shades_classic theme
|
||||
const bar1 = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
|
||||
|
||||
// start the progress bar with a total value of 200 and start value of 0
|
||||
bar1.start(200, 0);
|
||||
|
||||
// update the current value in your application..
|
||||
bar1.update(100);
|
||||
|
||||
// stop the progress bar
|
||||
bar1.stop();
|
||||
```
|
||||
|
||||
Single Bar Mode
|
||||
-----------------------------------
|
||||
|
||||

|
||||
|
||||
### Example ###
|
||||
|
||||
```js
|
||||
const cliProgress = require('cli-progress');
|
||||
|
||||
// create new progress bar
|
||||
const b1 = new cliProgress.SingleBar({
|
||||
format: 'CLI Progress |' + _colors.cyan('{bar}') + '| {percentage}% || {value}/{total} Chunks || Speed: {speed}',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true
|
||||
});
|
||||
|
||||
// initialize the bar - defining payload token "speed" with the default value "N/A"
|
||||
b1.start(200, 0, {
|
||||
speed: "N/A"
|
||||
});
|
||||
|
||||
// update values
|
||||
b1.increment();
|
||||
b1.update(20);
|
||||
|
||||
// stop the bar
|
||||
b1.stop();
|
||||
```
|
||||
|
||||
### Constructor ###
|
||||
|
||||
Initialize a new Progress bar. An instance can be used **multiple** times! it's not required to re-create it!
|
||||
|
||||
```js
|
||||
const cliProgress = require('cli-progress');
|
||||
|
||||
const <instance> = new cliProgress.SingleBar(options:object [, preset:object]);
|
||||
```
|
||||
|
||||
#### Options ####
|
||||
|
||||
|
||||
### ::start() ###
|
||||
|
||||
Starts the progress bar and set the total and initial value
|
||||
|
||||
```js
|
||||
<instance>.start(totalValue:int, startValue:int [, payload:object = {}]);
|
||||
```
|
||||
|
||||
### ::update() ###
|
||||
|
||||
Sets the current progress value and optionally the payload with values of custom tokens as a second parameter. To update payload only, set currentValue to `null`.
|
||||
|
||||
```js
|
||||
<instance>.update([currentValue:int [, payload:object = {}]]);
|
||||
|
||||
// update progress without altering value
|
||||
<instance>.update([payload:object = {}]);
|
||||
```
|
||||
|
||||
### ::increment() ###
|
||||
|
||||
Increases the current progress value by a specified amount (default +1). Update payload optionally
|
||||
|
||||
```js
|
||||
<instance>.increment([delta:int [, payload:object = {}]]);
|
||||
|
||||
// delta=1 assumed
|
||||
<instance>.increment(payload:object = {}]);
|
||||
```
|
||||
|
||||
### ::setTotal() ###
|
||||
|
||||
Sets the total progress value while progressbar is active. Especially useful handling dynamic tasks.
|
||||
|
||||
```js
|
||||
<instance>.setTotal(totalValue:int);
|
||||
```
|
||||
|
||||
### ::stop() ###
|
||||
|
||||
Stops the progress bar and go to next line
|
||||
|
||||
```js
|
||||
<instance>.stop();
|
||||
```
|
||||
|
||||
### ::updateETA() ###
|
||||
|
||||
Force eta calculation update (long running processes) without altering the progress values.
|
||||
|
||||
Note: you may want to increase `etaBuffer` size - otherwise it can cause `INF` eta values in case the value didn't changed within the time series.
|
||||
|
||||
```js
|
||||
<instance>.updateETA();
|
||||
```
|
||||
|
||||
|
||||
Multi Bar Mode
|
||||
-----------------------------------
|
||||
|
||||

|
||||
|
||||
### Example ###
|
||||
|
||||
```js
|
||||
const cliProgress = require('cli-progress');
|
||||
|
||||
// create new container
|
||||
const multibar = new cliProgress.MultiBar({
|
||||
clearOnComplete: false,
|
||||
hideCursor: true
|
||||
|
||||
}, cliProgress.Presets.shades_grey);
|
||||
|
||||
// add bars
|
||||
const b1 = multibar.create(200, 0);
|
||||
const b2 = multibar.create(1000, 0);
|
||||
|
||||
// control bars
|
||||
b1.increment();
|
||||
b2.update(20, {filename: "helloworld.txt"});
|
||||
|
||||
// stop all bars
|
||||
multibar.stop();
|
||||
```
|
||||
|
||||
### Constructor ###
|
||||
|
||||
Initialize a new multiprogress container. Bars need to be added. The options/presets are used for each single bar!
|
||||
|
||||
```js
|
||||
const cliProgress = require('cli-progress');
|
||||
|
||||
const <instance> = new cliProgress.MultiBar(options:object [, preset:object]);
|
||||
```
|
||||
|
||||
### ::create() ###
|
||||
|
||||
Adds a new progress bar to the container and starts the bar. Returns regular `SingleBar` object which can be individually controlled.
|
||||
|
||||
```js
|
||||
const <barInstance> = <instance>.create(totalValue:int, startValue:int [, payload:object = {}]);
|
||||
```
|
||||
|
||||
### ::remove() ###
|
||||
|
||||
Removes an existing bar from the multi progress container.
|
||||
|
||||
```js
|
||||
<instance>.remove(<barInstance>:object);
|
||||
```
|
||||
|
||||
### ::stop() ###
|
||||
|
||||
Stops the all progress bars
|
||||
|
||||
```js
|
||||
<instance>.stop();
|
||||
```
|
||||
|
||||
Options
|
||||
-----------------------------------
|
||||
|
||||
The following options can be changed
|
||||
|
||||
- `format` (type:string|function) - progress bar output format @see format section
|
||||
- `fps` (type:float) - the maximum update rate (default: 10)
|
||||
- `stream` (type:stream) - output stream to use (default: `process.stderr`)
|
||||
- `stopOnComplete` (type:boolean) - automatically call `stop()` when the value reaches the total (default: false)
|
||||
- `clearOnComplete` (type:boolean) - clear the progress bar on complete / `stop()` call (default: false)
|
||||
- `barsize` (type:int) - the length of the progress bar in chars (default: 40)
|
||||
- `align` (type:char) - position of the progress bar - 'left' (default), 'right' or 'center'
|
||||
- `barCompleteChar` (type:char) - character to use as "complete" indicator in the bar (default: "=")
|
||||
- `barIncompleteChar` (type:char) - character to use as "incomplete" indicator in the bar (default: "-")
|
||||
- `hideCursor` (type:boolean) - hide the cursor during progress operation; restored on complete (default: false) - pass `null` to keep terminal settings
|
||||
- `linewrap` (type:boolean) - disable line wrapping (default: false) - pass `null` to keep terminal settings; pass `true` to add linebreaks automatically (not recommended)
|
||||
- `etaBuffer` (type:int) - number of updates with which to calculate the eta; higher numbers give a more stable eta (default: 10)
|
||||
- `etaAsynchronousUpdate` (type:boolean) - trigger an eta calculation update during asynchronous rendering trigger using the current value - should only be used for long running processes in conjunction with lof `fps` values and large `etaBuffer` (default: false)
|
||||
- `synchronousUpdate` (type:boolean) - trigger redraw during `update()` in case threshold time x2 is exceeded (default: true) - limited to single bar usage
|
||||
- `noTTYOutput` (type:boolean) - enable scheduled output to notty streams - e.g. redirect to files (default: false)
|
||||
- `notTTYSchedule` (type:int) - set the output schedule/interval for notty output in `ms` (default: 2000ms)
|
||||
- `emptyOnZero` (type:boolean) - display progress bars with 'total' of zero(0) as empty, not full (default: false)
|
||||
- `forceRedraw` (type:boolean) - trigger redraw on every frame even if progress remains the same; can be useful if progress bar gets overwritten by other concurrent writes to the terminal (default: false)
|
||||
- `barGlue` (type:string) - a "glue" string between the complete and incomplete bar elements used to insert ascii control sequences for colorization (default: empty) - Note: in case you add visible "glue" characters the barsize will be increased by the length of the glue!
|
||||
- `autopadding` (type: boolean) - add padding chars to formatted time and percentage to force fixed width (default: false) - Note: handled standard format functions!
|
||||
- `autopaddingChar` (type: string) - the character sequence used for autopadding (default: " ") - Note: due to performance optimizations this value requires a length of 3 identical chars
|
||||
- `formatBar` (type: function) - a custom bar formatter function which renders the bar-element (default: [format-bar.js](lib/format-bar.js))
|
||||
- `formatTime` (type: function) - a custom timer formatter function which renders the formatted time elements like `eta_formatted` and `duration-formatted` (default: [format-time.js](lib/format-time.js))
|
||||
- `formatValue` (type: function) - a custom value formatter function which renders all other values (default: [format-value.js](lib/format-value.js))
|
||||
|
||||
Events
|
||||
-----------------------------------
|
||||
|
||||
The classes extends [EventEmitter](https://nodejs.org/api/events.html) which allows you to hook into different events.
|
||||
|
||||
See [event docs](docs/events.md) for detailed information + examples.
|
||||
|
||||
Bar Formatting
|
||||
-----------------------------------
|
||||
|
||||
The progressbar can be customized by using the following build-in placeholders. They can be combined in any order.
|
||||
|
||||
- `{bar}` - the progress bar, customizable by the options **barsize**, **barCompleteString** and **barIncompleteString**
|
||||
- `{percentage}` - the current progress in percent (0-100)
|
||||
- `{total}` - the end value
|
||||
- `{value}` - the current value set by last `update()` call
|
||||
- `{eta}` - expected time of accomplishment in seconds (limmited to 115days, otherwise INF is displayed)
|
||||
- `{duration}` - elapsed time in seconds
|
||||
- `{eta_formatted}` - expected time of accomplishment formatted into appropriate units
|
||||
- `{duration_formatted}` - elapsed time formatted into appropriate units
|
||||
|
||||
### Example ###
|
||||
|
||||
```js
|
||||
const opt = {
|
||||
format: 'progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}'
|
||||
}
|
||||
```
|
||||
|
||||
is rendered as
|
||||
|
||||
```
|
||||
progress [========================================] 100% | ETA: 0s | 200/200
|
||||
```
|
||||
|
||||
Custom formatters
|
||||
-----------------------------------
|
||||
|
||||
Instead of a "static" format string it is also possible to pass a custom callback function as formatter.
|
||||
For a full example (including params) take a look on `lib/formatter.js`
|
||||
|
||||
### Example 1 ###
|
||||
|
||||
```js
|
||||
function formatter(options, params, payload){
|
||||
|
||||
// bar grows dynamically by current progress - no whitespaces are added
|
||||
const bar = options.barCompleteString.substr(0, Math.round(params.progress*options.barsize));
|
||||
|
||||
// end value reached ?
|
||||
// change color to green when finished
|
||||
if (params.value >= params.total){
|
||||
return '# ' + _colors.grey(payload.task) + ' ' + _colors.green(params.value + '/' + params.total) + ' --[' + bar + ']-- ';
|
||||
}else{
|
||||
return '# ' + payload.task + ' ' + _colors.yellow(params.value + '/' + params.total) + ' --[' + bar + ']-- ';
|
||||
}
|
||||
}
|
||||
|
||||
const opt = {
|
||||
format: formatter
|
||||
}
|
||||
```
|
||||
|
||||
is rendered as
|
||||
|
||||
```
|
||||
# Task 1 0/200 --[]--
|
||||
# Task 1 98/200 --[████████████████████]--
|
||||
# Task 1 200/200 --[████████████████████████████████████████]--
|
||||
```
|
||||
|
||||
|
||||
### Example 2 ###
|
||||
|
||||
You can also access the default format functions to use them within your formatter:
|
||||
|
||||
```js
|
||||
const {TimeFormat, ValueFormat, BarFormat, Formatter} = require('cli-progess').Format;
|
||||
...
|
||||
```
|
||||
|
||||
Examples
|
||||
---------------------------------------------
|
||||
|
||||
### Example 1 - Set Options ###
|
||||
|
||||
```js
|
||||
// change the progress characters
|
||||
// set fps limit to 5
|
||||
// change the output stream and barsize
|
||||
const bar = new _progress.Bar({
|
||||
barCompleteChar: '#',
|
||||
barIncompleteChar: '.',
|
||||
fps: 5,
|
||||
stream: process.stdout,
|
||||
barsize: 65,
|
||||
position: 'center'
|
||||
});
|
||||
```
|
||||
|
||||
### Example 2 - Change Styles defined by Preset ###
|
||||
|
||||
```js
|
||||
// uee shades preset
|
||||
// change the barsize
|
||||
const bar = new _progress.Bar({
|
||||
barsize: 65,
|
||||
position: 'right'
|
||||
}, _progress.Presets.shades_grey);
|
||||
```
|
||||
|
||||
### Example 3 - Custom Payload ###
|
||||
|
||||
The payload object keys should only contain keys matching standard `\w+` regex!
|
||||
|
||||
```js
|
||||
// create new progress bar with custom token "speed"
|
||||
const bar = new _progress.Bar({
|
||||
format: 'progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit'
|
||||
});
|
||||
|
||||
// initialize the bar - set payload token "speed" with the default value "N/A"
|
||||
bar.start(200, 0, {
|
||||
speed: "N/A"
|
||||
});
|
||||
|
||||
// some code/update loop
|
||||
// ...
|
||||
|
||||
// update bar value. set custom token "speed" to 125
|
||||
bar.update(5, {
|
||||
speed: '125'
|
||||
});
|
||||
|
||||
// process finished
|
||||
bar.stop();
|
||||
```
|
||||
|
||||
### Example 4 - Custom Presets ###
|
||||
|
||||
**File** `myPreset.js`
|
||||
|
||||
```js
|
||||
const _colors = require('colors');
|
||||
|
||||
module.exports = {
|
||||
format: _colors.red(' {bar}') + ' {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591'
|
||||
};
|
||||
```
|
||||
|
||||
**Application**
|
||||
|
||||
```js
|
||||
const myPreset = require('./myPreset.js');
|
||||
|
||||
const bar = new _progress.Bar({
|
||||
barsize: 65
|
||||
}, myPreset);
|
||||
```
|
||||
|
||||
|
||||
Presets/Themes
|
||||
---------------------------------------------
|
||||
|
||||
Need a more modern appearance ? **cli-progress** supports predefined themes via presets. You are welcome to add your custom one :)
|
||||
|
||||
But keep in mind that a lot of the "special-chars" rely on Unicode - it might not work as expected on legacy systems.
|
||||
|
||||
### Default Presets ###
|
||||
|
||||
The following presets are included by default
|
||||
|
||||
* **legacy** - Styles as of cli-progress v1.3.0
|
||||
* **shades-classic** - Unicode background shades are used for the bar
|
||||
* **shades-grey** - Unicode background shades with grey bar
|
||||
* **rect** - Unicode Rectangles
|
||||
|
||||
|
||||
Compatibility
|
||||
---------------------------------------------
|
||||
|
||||
**cli-progress** is designed for linux/macOS/container applications which mostly providing standard compliant tty terminals/shells. In non-tty mode it is suitable to be used with logging daemons (cyclic output).
|
||||
|
||||
It also works with PowerShell on Windows 10 - the legacy command prompt on outdated Windows versions won't work as expected and is not supported!
|
||||
|
||||
Any Questions ? Report a Bug ? Enhancements ?
|
||||
---------------------------------------------
|
||||
Please open a new issue on [GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues)
|
||||
|
||||
License
|
||||
-------
|
||||
CLI-Progress is OpenSource and licensed under the Terms of [The MIT License (X11)](http://opensource.org/licenses/MIT). You're welcome to [contribute](https://github.com/AndiDittrich/Node.CLI-Progress/blob/master/CONTRIBUTE.md)!
|
21
node_modules/cli-progress/cli-progress.js
generated
vendored
Normal file
21
node_modules/cli-progress/cli-progress.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
const _SingleBar = require('./lib/single-bar');
|
||||
const _MultiBar = require('./lib/multi-bar');
|
||||
const _Presets = require('./presets/index');
|
||||
const _Formatter = require('./lib/formatter');
|
||||
const _defaultFormatValue = require('./lib/format-value');
|
||||
const _defaultFormatBar = require('./lib/format-bar');
|
||||
const _defaultFormatTime = require('./lib/format-time');
|
||||
|
||||
// sub-module access
|
||||
module.exports = {
|
||||
Bar: _SingleBar,
|
||||
SingleBar: _SingleBar,
|
||||
MultiBar: _MultiBar,
|
||||
Presets: _Presets,
|
||||
Format: {
|
||||
Formatter: _Formatter,
|
||||
BarFormat: _defaultFormatBar,
|
||||
ValueFormat: _defaultFormatValue,
|
||||
TimeFormat: _defaultFormatTime
|
||||
}
|
||||
};
|
73
node_modules/cli-progress/lib/eta.js
generated
vendored
Normal file
73
node_modules/cli-progress/lib/eta.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
// ETA calculation
|
||||
class ETA{
|
||||
|
||||
constructor(length, initTime, initValue){
|
||||
// size of eta buffer
|
||||
this.etaBufferLength = length || 100;
|
||||
|
||||
// eta buffer with initial values
|
||||
this.valueBuffer = [initValue];
|
||||
this.timeBuffer = [initTime];
|
||||
|
||||
// eta time value
|
||||
this.eta = '0';
|
||||
}
|
||||
|
||||
// add new values to calculation buffer
|
||||
update(time, value, total){
|
||||
this.valueBuffer.push(value);
|
||||
this.timeBuffer.push(time);
|
||||
|
||||
// trigger recalculation
|
||||
this.calculate(total-value);
|
||||
}
|
||||
|
||||
// fetch estimated time
|
||||
getTime(){
|
||||
return this.eta;
|
||||
}
|
||||
|
||||
// eta calculation - request number of remaining events
|
||||
calculate(remaining){
|
||||
// get number of samples in eta buffer
|
||||
const currentBufferSize = this.valueBuffer.length;
|
||||
const buffer = Math.min(this.etaBufferLength, currentBufferSize);
|
||||
|
||||
const v_diff = this.valueBuffer[currentBufferSize - 1] - this.valueBuffer[currentBufferSize - buffer];
|
||||
const t_diff = this.timeBuffer[currentBufferSize - 1] - this.timeBuffer[currentBufferSize - buffer];
|
||||
|
||||
// get progress per ms
|
||||
const vt_rate = v_diff/t_diff;
|
||||
|
||||
// strip past elements
|
||||
this.valueBuffer = this.valueBuffer.slice(-this.etaBufferLength);
|
||||
this.timeBuffer = this.timeBuffer.slice(-this.etaBufferLength);
|
||||
|
||||
// eq: vt_rate *x = total
|
||||
const eta = Math.ceil(remaining/vt_rate/1000);
|
||||
|
||||
// check values
|
||||
if (isNaN(eta)){
|
||||
this.eta = 'NULL';
|
||||
|
||||
// +/- Infinity --- NaN already handled
|
||||
}else if (!isFinite(eta)){
|
||||
this.eta = 'INF';
|
||||
|
||||
// > 10M s ? - set upper display limit ~115days (1e7/60/60/24)
|
||||
}else if (eta > 1e7){
|
||||
this.eta = 'INF';
|
||||
|
||||
// negative ?
|
||||
}else if (eta < 0){
|
||||
this.eta = 0;
|
||||
|
||||
}else{
|
||||
// assign
|
||||
this.eta = eta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ETA;
|
11
node_modules/cli-progress/lib/format-bar.js
generated
vendored
Normal file
11
node_modules/cli-progress/lib/format-bar.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// format bar
|
||||
module.exports = function formatBar(progress, options){
|
||||
// calculate barsize
|
||||
const completeSize = Math.round(progress*options.barsize);
|
||||
const incompleteSize = options.barsize-completeSize;
|
||||
|
||||
// generate bar string by stripping the pre-rendered strings
|
||||
return options.barCompleteString.substr(0, completeSize) +
|
||||
options.barGlue +
|
||||
options.barIncompleteString.substr(0, incompleteSize);
|
||||
}
|
34
node_modules/cli-progress/lib/format-time.js
generated
vendored
Normal file
34
node_modules/cli-progress/lib/format-time.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// default time format
|
||||
|
||||
// format a number of seconds into hours and minutes as appropriate
|
||||
module.exports = function formatTime(t, options, roundToMultipleOf){
|
||||
function round(input) {
|
||||
if (roundToMultipleOf) {
|
||||
return roundToMultipleOf * Math.round(input / roundToMultipleOf);
|
||||
} else {
|
||||
return input
|
||||
}
|
||||
}
|
||||
|
||||
// leading zero padding
|
||||
function autopadding(v){
|
||||
return (options.autopaddingChar + v).slice(-2);
|
||||
}
|
||||
|
||||
// > 1h ?
|
||||
if (t > 3600) {
|
||||
return autopadding(Math.floor(t / 3600)) + 'h' + autopadding(round((t % 3600) / 60)) + 'm';
|
||||
|
||||
// > 60s ?
|
||||
} else if (t > 60) {
|
||||
return autopadding(Math.floor(t / 60)) + 'm' + autopadding(round((t % 60))) + 's';
|
||||
|
||||
// > 10s ?
|
||||
} else if (t > 10) {
|
||||
return autopadding(round(t)) + 's';
|
||||
|
||||
// default: don't apply round to multiple
|
||||
}else{
|
||||
return autopadding(t) + 's';
|
||||
}
|
||||
}
|
22
node_modules/cli-progress/lib/format-value.js
generated
vendored
Normal file
22
node_modules/cli-progress/lib/format-value.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// default value format (apply autopadding)
|
||||
|
||||
// format valueset
|
||||
module.exports = function formatValue(v, options, type){
|
||||
// no autopadding ? passthrough
|
||||
if (options.autopadding !== true){
|
||||
return v;
|
||||
}
|
||||
|
||||
// padding
|
||||
function autopadding(value, length){
|
||||
return (options.autopaddingChar + value).slice(-length);
|
||||
}
|
||||
|
||||
switch (type){
|
||||
case 'percentage':
|
||||
return autopadding(v, 3);
|
||||
|
||||
default:
|
||||
return v;
|
||||
}
|
||||
}
|
80
node_modules/cli-progress/lib/formatter.js
generated
vendored
Normal file
80
node_modules/cli-progress/lib/formatter.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
const _stringWidth = require('string-width');
|
||||
const _defaultFormatValue = require('./format-value');
|
||||
const _defaultFormatBar = require('./format-bar');
|
||||
const _defaultFormatTime = require('./format-time');
|
||||
|
||||
// generic formatter
|
||||
module.exports = function defaultFormatter(options, params, payload){
|
||||
|
||||
// copy format string
|
||||
let s = options.format;
|
||||
|
||||
// custom time format set ?
|
||||
const formatTime = options.formatTime || _defaultFormatTime;
|
||||
|
||||
// custom value format set ?
|
||||
const formatValue = options.formatValue || _defaultFormatValue;
|
||||
|
||||
// custom bar format set ?
|
||||
const formatBar = options.formatBar || _defaultFormatBar;
|
||||
|
||||
// calculate progress in percent
|
||||
const percentage = Math.floor(params.progress*100) + '';
|
||||
|
||||
// bar stopped and stopTime set ?
|
||||
const stopTime = params.stopTime || Date.now();
|
||||
|
||||
// calculate elapsed time
|
||||
const elapsedTime = Math.round((stopTime - params.startTime)/1000);
|
||||
|
||||
// merges data from payload and calculated
|
||||
const context = Object.assign({}, payload, {
|
||||
bar: formatBar(params.progress, options),
|
||||
|
||||
percentage: formatValue(percentage, options, 'percentage'),
|
||||
total: formatValue(params.total, options, 'total'),
|
||||
value: formatValue(params.value, options, 'value'),
|
||||
|
||||
eta: formatValue(params.eta, options, 'eta'),
|
||||
eta_formatted: formatTime(params.eta, options, 5),
|
||||
|
||||
duration: formatValue(elapsedTime, options, 'duration'),
|
||||
duration_formatted: formatTime(elapsedTime, options, 1)
|
||||
});
|
||||
|
||||
// assign placeholder tokens
|
||||
s = s.replace(/\{(\w+)\}/g, function(match, key){
|
||||
// key exists within payload/context
|
||||
if (typeof context[key] !== 'undefined') {
|
||||
return context[key];
|
||||
}
|
||||
|
||||
// no changes to unknown values
|
||||
return match;
|
||||
});
|
||||
|
||||
// calculate available whitespace (2 characters margin of error)
|
||||
const fullMargin = Math.max(0, params.maxWidth - _stringWidth(s) -2);
|
||||
const halfMargin = Math.floor(fullMargin / 2);
|
||||
|
||||
// distribute available whitespace according to position
|
||||
switch (options.align) {
|
||||
|
||||
// fill start-of-line with whitespaces
|
||||
case 'right':
|
||||
s = (fullMargin > 0) ? ' '.repeat(fullMargin) + s : s;
|
||||
break;
|
||||
|
||||
// distribute whitespaces to left+right
|
||||
case 'center':
|
||||
s = (halfMargin > 0) ? ' '.repeat(halfMargin) + s : s;
|
||||
break;
|
||||
|
||||
// default: left align, no additional whitespaces
|
||||
case 'left':
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
212
node_modules/cli-progress/lib/generic-bar.js
generated
vendored
Normal file
212
node_modules/cli-progress/lib/generic-bar.js
generated
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
const _ETA = require('./eta');
|
||||
const _Terminal = require('./terminal');
|
||||
const _formatter = require('./formatter');
|
||||
const _EventEmitter = require('events');
|
||||
|
||||
// Progress-Bar constructor
|
||||
module.exports = class GenericBar extends _EventEmitter{
|
||||
|
||||
constructor(options){
|
||||
super();
|
||||
|
||||
// store options
|
||||
this.options = options;
|
||||
|
||||
// store terminal instance
|
||||
this.terminal = (this.options.terminal) ? this.options.terminal : new _Terminal(this.options.stream);
|
||||
|
||||
// the current bar value
|
||||
this.value = 0;
|
||||
|
||||
// the end value of the bar
|
||||
this.total = 100;
|
||||
|
||||
// last drawn string - only render on change!
|
||||
this.lastDrawnString = null;
|
||||
|
||||
// start time (used for eta calculation)
|
||||
this.startTime = null;
|
||||
|
||||
// stop time (used for duration calculation)
|
||||
this.stopTime = null;
|
||||
|
||||
// last update time
|
||||
this.lastRedraw = Date.now();
|
||||
|
||||
// default eta calculator (will be re-create on start)
|
||||
this.eta = new _ETA(this.options.etaBufferLength, 0, 0);
|
||||
|
||||
// payload data
|
||||
this.payload = {};
|
||||
|
||||
// progress bar active ?
|
||||
this.isActive = false;
|
||||
|
||||
// use default formatter or custom one ?
|
||||
this.formatter = (typeof this.options.format === 'function') ? this.options.format : _formatter;
|
||||
}
|
||||
|
||||
// internal render function
|
||||
render(){
|
||||
// calculate the normalized current progress
|
||||
let progress = (this.value/this.total);
|
||||
|
||||
// handle NaN Errors caused by total=0. Set to complete in this case
|
||||
if (isNaN(progress)){
|
||||
progress = (this.options && this.options.emptyOnZero) ? 0.0 : 1.0;
|
||||
}
|
||||
|
||||
// limiter
|
||||
progress = Math.min(Math.max(progress, 0.0), 1.0);
|
||||
|
||||
// formatter params
|
||||
const params = {
|
||||
progress: progress,
|
||||
eta: this.eta.getTime(),
|
||||
startTime: this.startTime,
|
||||
stopTime: this.stopTime,
|
||||
total: this.total,
|
||||
value: this.value,
|
||||
maxWidth: this.terminal.getWidth()
|
||||
};
|
||||
|
||||
// automatic eta update ? (long running processes)
|
||||
if (this.options.etaAsynchronousUpdate){
|
||||
this.updateETA();
|
||||
}
|
||||
|
||||
// format string
|
||||
const s = this.formatter(this.options, params, this.payload);
|
||||
|
||||
const forceRedraw = this.options.forceRedraw
|
||||
// force redraw in notty-mode!
|
||||
|| (this.options.noTTYOutput && !this.terminal.isTTY());
|
||||
|
||||
// string changed ? only trigger redraw on change!
|
||||
if (forceRedraw || this.lastDrawnString != s){
|
||||
// trigger event
|
||||
this.emit('redraw-pre');
|
||||
|
||||
// set cursor to start of line
|
||||
this.terminal.cursorTo(0, null);
|
||||
|
||||
// write output
|
||||
this.terminal.write(s);
|
||||
|
||||
// clear to the right from cursor
|
||||
this.terminal.clearRight();
|
||||
|
||||
// store string
|
||||
this.lastDrawnString = s;
|
||||
|
||||
// set last redraw time
|
||||
this.lastRedraw = Date.now();
|
||||
|
||||
// trigger event
|
||||
this.emit('redraw-post');
|
||||
}
|
||||
}
|
||||
|
||||
// start the progress bar
|
||||
start(total, startValue, payload){
|
||||
// set initial values
|
||||
this.value = startValue || 0;
|
||||
this.total = (typeof total !== 'undefined' && total >= 0) ? total : 100;
|
||||
|
||||
// store payload (optional)
|
||||
this.payload = payload || {};
|
||||
|
||||
// store start time for duration+eta calculation
|
||||
this.startTime = Date.now();
|
||||
|
||||
// reset string line buffer (redraw detection)
|
||||
this.lastDrawnString = '';
|
||||
|
||||
// initialize eta buffer
|
||||
this.eta = new _ETA(this.options.etaBufferLength, this.startTime, this.value);
|
||||
|
||||
// set flag
|
||||
this.isActive = true;
|
||||
|
||||
// start event
|
||||
this.emit('start', total, startValue);
|
||||
}
|
||||
|
||||
// stop the bar
|
||||
stop(){
|
||||
// set flag
|
||||
this.isActive = false;
|
||||
|
||||
// store stop timestamp to get total duration
|
||||
this.stopTime = new Date();
|
||||
|
||||
// stop event
|
||||
this.emit('stop', this.total, this.value);
|
||||
}
|
||||
|
||||
// update the bar value
|
||||
// update(value, payload)
|
||||
// update(payload)
|
||||
update(arg0, arg1 = {}){
|
||||
// value set ?
|
||||
// update(value, [payload]);
|
||||
if (typeof arg0 === 'number') {
|
||||
// update value
|
||||
this.value = arg0;
|
||||
|
||||
// add new value; recalculate eta
|
||||
this.eta.update(Date.now(), arg0, this.total);
|
||||
}
|
||||
|
||||
// extract payload
|
||||
// update(value, payload)
|
||||
// update(payload)
|
||||
const payloadData = ((typeof arg0 === 'object') ? arg0 : arg1) || {};
|
||||
|
||||
// update event (before stop() is called)
|
||||
this.emit('update', this.total, this.value);
|
||||
|
||||
// merge payload
|
||||
for (const key in payloadData){
|
||||
this.payload[key] = payloadData[key];
|
||||
}
|
||||
|
||||
// limit reached ? autostop set ?
|
||||
if (this.value >= this.getTotal() && this.options.stopOnComplete) {
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
|
||||
// update the bar value
|
||||
// increment(delta, payload)
|
||||
// increment(payload)
|
||||
increment(arg0 = 1, arg1 = {}){
|
||||
// increment([payload]) => step=1
|
||||
// handle the use case when `step` is omitted but payload is passed
|
||||
if (typeof arg0 === 'object') {
|
||||
this.update(this.value + 1, arg0);
|
||||
|
||||
// increment([step=1], [payload={}])
|
||||
}else{
|
||||
this.update(this.value + arg0, arg1);
|
||||
}
|
||||
}
|
||||
|
||||
// get the total (limit) value
|
||||
getTotal(){
|
||||
return this.total;
|
||||
}
|
||||
|
||||
// set the total (limit) value
|
||||
setTotal(total){
|
||||
if (typeof total !== 'undefined' && total >= 0){
|
||||
this.total = total;
|
||||
}
|
||||
}
|
||||
|
||||
// force eta calculation update (long running processes)
|
||||
updateETA(){
|
||||
// add new value; recalculate eta
|
||||
this.eta.update(Date.now(), this.value, this.total);
|
||||
}
|
||||
}
|
201
node_modules/cli-progress/lib/multi-bar.js
generated
vendored
Normal file
201
node_modules/cli-progress/lib/multi-bar.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
const _Terminal = require('./terminal');
|
||||
const _BarElement = require('./generic-bar');
|
||||
const _options = require('./options');
|
||||
const _EventEmitter = require('events');
|
||||
|
||||
// Progress-Bar constructor
|
||||
module.exports = class MultiBar extends _EventEmitter{
|
||||
|
||||
constructor(options, preset){
|
||||
super();
|
||||
|
||||
// list of bars
|
||||
this.bars = [];
|
||||
|
||||
// parse+store options
|
||||
this.options = _options.parse(options, preset);
|
||||
|
||||
// disable synchronous updates
|
||||
this.options.synchronousUpdate = false;
|
||||
|
||||
// store terminal instance
|
||||
this.terminal = (this.options.terminal) ? this.options.terminal : new _Terminal(this.options.stream);
|
||||
|
||||
// the update timer
|
||||
this.timer = null;
|
||||
|
||||
// progress bar active ?
|
||||
this.isActive = false;
|
||||
|
||||
// update interval
|
||||
this.schedulingRate = (this.terminal.isTTY() ? this.options.throttleTime : this.options.notTTYSchedule);
|
||||
}
|
||||
|
||||
// add a new bar to the stack
|
||||
create(total, startValue, payload){
|
||||
// progress updates are only visible in TTY mode!
|
||||
if (this.options.noTTYOutput === false && this.terminal.isTTY() === false){
|
||||
return;
|
||||
}
|
||||
|
||||
// create new bar element
|
||||
const bar = new _BarElement(this.options);
|
||||
|
||||
// store bar
|
||||
this.bars.push(bar);
|
||||
|
||||
// multiprogress already active ?
|
||||
if (!this.isActive){
|
||||
// hide the cursor ?
|
||||
if (this.options.hideCursor === true){
|
||||
this.terminal.cursor(false);
|
||||
}
|
||||
|
||||
// disable line wrapping ?
|
||||
if (this.options.linewrap === false){
|
||||
this.terminal.lineWrapping(false);
|
||||
}
|
||||
|
||||
// initialize update timer
|
||||
this.timer = setTimeout(this.update.bind(this), this.schedulingRate);
|
||||
}
|
||||
|
||||
// set flag
|
||||
this.isActive = true;
|
||||
|
||||
// start progress bar
|
||||
bar.start(total, startValue, payload);
|
||||
|
||||
// trigger event
|
||||
this.emit('start');
|
||||
|
||||
// return new instance
|
||||
return bar;
|
||||
}
|
||||
|
||||
// remove a bar from the stack
|
||||
remove(bar){
|
||||
// find element
|
||||
const index = this.bars.indexOf(bar);
|
||||
|
||||
// element found ?
|
||||
if (index < 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove element
|
||||
this.bars.splice(index, 1);
|
||||
|
||||
// force update
|
||||
this.update();
|
||||
|
||||
// clear bottom
|
||||
this.terminal.newline();
|
||||
this.terminal.clearBottom();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// internal update routine
|
||||
update(){
|
||||
// stop timer
|
||||
if (this.timer){
|
||||
clearTimeout(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
|
||||
// trigger event
|
||||
this.emit('update-pre');
|
||||
|
||||
// reset cursor
|
||||
this.terminal.cursorRelativeReset();
|
||||
|
||||
// trigger event
|
||||
this.emit('redraw-pre');
|
||||
|
||||
// update each bar
|
||||
for (let i=0; i< this.bars.length; i++){
|
||||
// add new line ?
|
||||
if (i > 0){
|
||||
this.terminal.newline();
|
||||
}
|
||||
|
||||
// render
|
||||
this.bars[i].render();
|
||||
}
|
||||
|
||||
// trigger event
|
||||
this.emit('redraw-post');
|
||||
|
||||
// add new line in notty mode!
|
||||
if (this.options.noTTYOutput && this.terminal.isTTY() === false){
|
||||
this.terminal.newline();
|
||||
this.terminal.newline();
|
||||
}
|
||||
|
||||
// next update
|
||||
this.timer = setTimeout(this.update.bind(this), this.schedulingRate);
|
||||
|
||||
// trigger event
|
||||
this.emit('update-post');
|
||||
|
||||
// stop if stopOnComplete and all bars stopped
|
||||
if (this.options.stopOnComplete && !this.bars.find(bar => bar.isActive)) {
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
|
||||
stop(){
|
||||
|
||||
// stop timer
|
||||
clearTimeout(this.timer);
|
||||
this.timer = null;
|
||||
|
||||
// set flag
|
||||
this.isActive = false;
|
||||
|
||||
// cursor hidden ?
|
||||
if (this.options.hideCursor === true){
|
||||
this.terminal.cursor(true);
|
||||
}
|
||||
|
||||
// re-enable line wrpaping ?
|
||||
if (this.options.linewrap === false){
|
||||
this.terminal.lineWrapping(true);
|
||||
}
|
||||
|
||||
// reset cursor
|
||||
this.terminal.cursorRelativeReset();
|
||||
|
||||
// trigger event
|
||||
this.emit('stop-pre-clear');
|
||||
|
||||
// clear line on complete ?
|
||||
if (this.options.clearOnComplete){
|
||||
// clear all bars
|
||||
this.terminal.clearBottom();
|
||||
|
||||
// or show final progress ?
|
||||
}else{
|
||||
// update each bar
|
||||
for (let i=0; i< this.bars.length; i++){
|
||||
// add new line ?
|
||||
if (i > 0){
|
||||
this.terminal.newline();
|
||||
}
|
||||
|
||||
// trigger final rendering
|
||||
this.bars[i].render();
|
||||
|
||||
// stop
|
||||
this.bars[i].stop();
|
||||
}
|
||||
|
||||
// new line on complete
|
||||
this.terminal.newline();
|
||||
}
|
||||
|
||||
// trigger event
|
||||
this.emit('stop');
|
||||
}
|
||||
}
|
95
node_modules/cli-progress/lib/options.js
generated
vendored
Normal file
95
node_modules/cli-progress/lib/options.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
// utility to merge defaults
|
||||
function mergeOption(v, defaultValue){
|
||||
if (typeof v === 'undefined' || v === null){
|
||||
return defaultValue;
|
||||
}else{
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
// set global options
|
||||
parse: function parse(rawOptions, preset){
|
||||
|
||||
// options storage
|
||||
const options = {};
|
||||
|
||||
// merge preset
|
||||
const opt = Object.assign({}, preset, rawOptions);
|
||||
|
||||
// the max update rate in fps (redraw will only triggered on value change)
|
||||
options.throttleTime = 1000 / (mergeOption(opt.fps, 10));
|
||||
|
||||
// the output stream to write on
|
||||
options.stream = mergeOption(opt.stream, process.stderr);
|
||||
|
||||
// external terminal provided ?
|
||||
options.terminal = mergeOption(opt.terminal, null);
|
||||
|
||||
// clear on finish ?
|
||||
options.clearOnComplete = mergeOption(opt.clearOnComplete, false);
|
||||
|
||||
// stop on finish ?
|
||||
options.stopOnComplete = mergeOption(opt.stopOnComplete, false);
|
||||
|
||||
// size of the progressbar in chars
|
||||
options.barsize = mergeOption(opt.barsize, 40);
|
||||
|
||||
// position of the progress bar - 'left' (default), 'right' or 'center'
|
||||
options.align = mergeOption(opt.align, 'left');
|
||||
|
||||
// hide the cursor ?
|
||||
options.hideCursor = mergeOption(opt.hideCursor, false);
|
||||
|
||||
// disable linewrapping ?
|
||||
options.linewrap = mergeOption(opt.linewrap, false);
|
||||
|
||||
// pre-render bar strings (performance)
|
||||
options.barCompleteString = (new Array(options.barsize + 1 ).join(opt.barCompleteChar || '='));
|
||||
options.barIncompleteString = (new Array(options.barsize + 1 ).join(opt.barIncompleteChar || '-'));
|
||||
|
||||
// glue sequence (control chars) between bar elements ?
|
||||
options.barGlue = mergeOption(opt.barGlue, '');
|
||||
|
||||
// the bar format
|
||||
options.format = mergeOption(opt.format, 'progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}');
|
||||
|
||||
// external time-format provided ?
|
||||
options.formatTime = mergeOption(opt.formatTime, null);
|
||||
|
||||
// external value-format provided ?
|
||||
options.formatValue = mergeOption(opt.formatValue, null);
|
||||
|
||||
// external bar-format provided ?
|
||||
options.formatBar = mergeOption(opt.formatBar, null);
|
||||
|
||||
// the number of results to average ETA over
|
||||
options.etaBufferLength = mergeOption(opt.etaBuffer, 10);
|
||||
|
||||
// automatic eta updates based on fps
|
||||
options.etaAsynchronousUpdate = mergeOption(opt.etaAsynchronousUpdate, false);
|
||||
|
||||
// allow synchronous updates ?
|
||||
options.synchronousUpdate = mergeOption(opt.synchronousUpdate, true);
|
||||
|
||||
// notty mode
|
||||
options.noTTYOutput = mergeOption(opt.noTTYOutput, false);
|
||||
|
||||
// schedule - 2s
|
||||
options.notTTYSchedule = mergeOption(opt.notTTYSchedule, 2000);
|
||||
|
||||
// emptyOnZero - false
|
||||
options.emptyOnZero = mergeOption(opt.emptyOnZero, false);
|
||||
|
||||
// force bar redraw even if progress did not change
|
||||
options.forceRedraw = mergeOption(opt.forceRedraw, false);
|
||||
|
||||
// automated padding to fixed width ?
|
||||
options.autopadding = mergeOption(opt.autopadding, false);
|
||||
|
||||
// autopadding character - empty in case autopadding is disabled
|
||||
options.autopaddingChar = options.autopadding ? mergeOption(opt.autopaddingChar, ' ') : '';
|
||||
|
||||
return options;
|
||||
}
|
||||
};
|
124
node_modules/cli-progress/lib/single-bar.js
generated
vendored
Normal file
124
node_modules/cli-progress/lib/single-bar.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
const _GenericBar = require('./generic-bar');
|
||||
const _options = require('./options');
|
||||
|
||||
// Progress-Bar constructor
|
||||
module.exports = class SingleBar extends _GenericBar{
|
||||
|
||||
constructor(options, preset){
|
||||
super(_options.parse(options, preset));
|
||||
|
||||
// the update timer
|
||||
this.timer = null;
|
||||
|
||||
// disable synchronous updates in notty mode
|
||||
if (this.options.noTTYOutput && this.terminal.isTTY() === false){
|
||||
this.options.synchronousUpdate = false;
|
||||
}
|
||||
|
||||
// update interval
|
||||
this.schedulingRate = (this.terminal.isTTY() ? this.options.throttleTime : this.options.notTTYSchedule);
|
||||
}
|
||||
|
||||
// internal render function
|
||||
render(){
|
||||
// stop timer
|
||||
if (this.timer){
|
||||
clearTimeout(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
|
||||
// run internal rendering
|
||||
super.render();
|
||||
|
||||
// add new line in notty mode!
|
||||
if (this.options.noTTYOutput && this.terminal.isTTY() === false){
|
||||
this.terminal.newline();
|
||||
}
|
||||
|
||||
// next update
|
||||
this.timer = setTimeout(this.render.bind(this), this.schedulingRate);
|
||||
}
|
||||
|
||||
update(current, payload){
|
||||
// timer inactive ?
|
||||
if (!this.timer) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.update(current, payload);
|
||||
|
||||
// trigger synchronous update ?
|
||||
// check for throttle time
|
||||
if (this.options.synchronousUpdate && (this.lastRedraw + this.options.throttleTime*2) < Date.now()){
|
||||
// force update
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
// start the progress bar
|
||||
start(total, startValue, payload){
|
||||
// progress updates are only visible in TTY mode!
|
||||
if (this.options.noTTYOutput === false && this.terminal.isTTY() === false){
|
||||
return;
|
||||
}
|
||||
|
||||
// save current cursor settings
|
||||
this.terminal.cursorSave();
|
||||
|
||||
// hide the cursor ?
|
||||
if (this.options.hideCursor === true){
|
||||
this.terminal.cursor(false);
|
||||
}
|
||||
|
||||
// disable line wrapping ?
|
||||
if (this.options.linewrap === false){
|
||||
this.terminal.lineWrapping(false);
|
||||
}
|
||||
|
||||
// initialize bar
|
||||
super.start(total, startValue, payload);
|
||||
|
||||
// redraw on start!
|
||||
this.render();
|
||||
}
|
||||
|
||||
// stop the bar
|
||||
stop(){
|
||||
// timer inactive ?
|
||||
if (!this.timer) {
|
||||
return;
|
||||
}
|
||||
|
||||
// trigger final rendering
|
||||
this.render();
|
||||
|
||||
// restore state
|
||||
super.stop();
|
||||
|
||||
// stop timer
|
||||
clearTimeout(this.timer);
|
||||
this.timer = null;
|
||||
|
||||
// cursor hidden ?
|
||||
if (this.options.hideCursor === true){
|
||||
this.terminal.cursor(true);
|
||||
}
|
||||
|
||||
// re-enable line wrapping ?
|
||||
if (this.options.linewrap === false){
|
||||
this.terminal.lineWrapping(true);
|
||||
}
|
||||
|
||||
// restore cursor on complete (position + settings)
|
||||
this.terminal.cursorRestore();
|
||||
|
||||
// clear line on complete ?
|
||||
if (this.options.clearOnComplete){
|
||||
this.terminal.cursorTo(0, null);
|
||||
this.terminal.clearLine();
|
||||
}else{
|
||||
// new line on complete
|
||||
this.terminal.newline();
|
||||
}
|
||||
}
|
||||
}
|
159
node_modules/cli-progress/lib/terminal.js
generated
vendored
Normal file
159
node_modules/cli-progress/lib/terminal.js
generated
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
const _readline = require('readline');
|
||||
|
||||
// low-level terminal interactions
|
||||
class Terminal{
|
||||
|
||||
constructor(outputStream){
|
||||
this.stream = outputStream;
|
||||
|
||||
// default: line wrapping enabled
|
||||
this.linewrap = true;
|
||||
|
||||
// current, relative y position
|
||||
this.dy = 0;
|
||||
}
|
||||
|
||||
// save cursor position + settings
|
||||
cursorSave(){
|
||||
if (!this.stream.isTTY){
|
||||
return;
|
||||
}
|
||||
|
||||
// save position
|
||||
this.stream.write('\x1B7');
|
||||
}
|
||||
|
||||
// restore last cursor position + settings
|
||||
cursorRestore(){
|
||||
if (!this.stream.isTTY){
|
||||
return;
|
||||
}
|
||||
|
||||
// restore cursor
|
||||
this.stream.write('\x1B8');
|
||||
}
|
||||
|
||||
// show/hide cursor
|
||||
cursor(enabled){
|
||||
if (!this.stream.isTTY){
|
||||
return;
|
||||
}
|
||||
|
||||
if (enabled){
|
||||
this.stream.write('\x1B[?25h');
|
||||
}else{
|
||||
this.stream.write('\x1B[?25l');
|
||||
}
|
||||
}
|
||||
|
||||
// change cursor positionn
|
||||
cursorTo(x=null, y=null){
|
||||
if (!this.stream.isTTY){
|
||||
return;
|
||||
}
|
||||
|
||||
// move cursor absolute
|
||||
_readline.cursorTo(this.stream, x, y);
|
||||
}
|
||||
|
||||
// change relative cursor position
|
||||
cursorRelative(dx=null, dy=null){
|
||||
if (!this.stream.isTTY){
|
||||
return;
|
||||
}
|
||||
|
||||
// store current position
|
||||
this.dy = this.dy + dy;
|
||||
|
||||
// move cursor relative
|
||||
_readline.moveCursor(this.stream, dx, dy);
|
||||
}
|
||||
|
||||
// relative reset
|
||||
cursorRelativeReset(){
|
||||
if (!this.stream.isTTY){
|
||||
return;
|
||||
}
|
||||
|
||||
// move cursor to initial line
|
||||
_readline.moveCursor(this.stream, 0, -this.dy);
|
||||
|
||||
// first char
|
||||
_readline.cursorTo(this.stream, 0, null);
|
||||
|
||||
// reset counter
|
||||
this.dy = 0;
|
||||
}
|
||||
|
||||
// clear to the right from cursor
|
||||
clearRight(){
|
||||
if (!this.stream.isTTY){
|
||||
return;
|
||||
}
|
||||
|
||||
_readline.clearLine(this.stream, 1);
|
||||
}
|
||||
|
||||
// clear the full line
|
||||
clearLine(){
|
||||
if (!this.stream.isTTY){
|
||||
return;
|
||||
}
|
||||
|
||||
_readline.clearLine(this.stream, 0);
|
||||
}
|
||||
|
||||
// clear everyting beyond the current line
|
||||
clearBottom(){
|
||||
if (!this.stream.isTTY){
|
||||
return;
|
||||
}
|
||||
|
||||
_readline.clearScreenDown(this.stream);
|
||||
}
|
||||
|
||||
// add new line; increment counter
|
||||
newline(){
|
||||
this.stream.write('\n');
|
||||
this.dy++;
|
||||
}
|
||||
|
||||
// write content to output stream
|
||||
// @TODO use string-width to strip length
|
||||
write(s){
|
||||
// line wrapping enabled ? trim output
|
||||
if (this.linewrap === true){
|
||||
this.stream.write(s.substr(0, this.getWidth()));
|
||||
}else{
|
||||
this.stream.write(s);
|
||||
}
|
||||
}
|
||||
|
||||
// control line wrapping
|
||||
lineWrapping(enabled){
|
||||
if (!this.stream.isTTY){
|
||||
return;
|
||||
}
|
||||
|
||||
// store state
|
||||
this.linewrap = enabled;
|
||||
if (enabled){
|
||||
this.stream.write('\x1B[?7h');
|
||||
}else{
|
||||
this.stream.write('\x1B[?7l');
|
||||
}
|
||||
}
|
||||
|
||||
// tty environment ?
|
||||
isTTY(){
|
||||
return (this.stream.isTTY === true);
|
||||
}
|
||||
|
||||
// get terminal width
|
||||
getWidth(){
|
||||
// set max width to 80 in tty-mode and 200 in notty-mode
|
||||
return this.stream.columns || (this.stream.isTTY ? 80 : 200);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Terminal;
|
46
node_modules/cli-progress/package.json
generated
vendored
Normal file
46
node_modules/cli-progress/package.json
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "cli-progress",
|
||||
"version": "3.9.0",
|
||||
"description": "easy to use progress-bar for command-line/terminal applications",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"tty",
|
||||
"terminal",
|
||||
"progress",
|
||||
"progressbar",
|
||||
"multibar",
|
||||
"bar",
|
||||
"status",
|
||||
"statusbar",
|
||||
"utility",
|
||||
"widget"
|
||||
],
|
||||
"homepage": "https://github.com/AndiDittrich/Node.CLI-Progress",
|
||||
"bugs": "https://github.com/AndiDittrich/Node.CLI-Progress/issues",
|
||||
"repository": "AndiDittrich/Node.CLI-Progress",
|
||||
"files": [
|
||||
"cli-progress.js",
|
||||
"lib/",
|
||||
"presets/"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint lib/**.js",
|
||||
"pretest": "npm run lint",
|
||||
"test": "mocha test/**/*.test.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"main": "./cli-progress.js",
|
||||
"author": "Andi Dittrich (https://andidittrich.com)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"colors": "^1.1.2",
|
||||
"string-width": "^4.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.4.0",
|
||||
"eslint-config-aenondynamics": "^0.2.0",
|
||||
"mocha": "^7.1.1"
|
||||
}
|
||||
}
|
11
node_modules/cli-progress/presets/index.js
generated
vendored
Normal file
11
node_modules/cli-progress/presets/index.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
const _legacy = require('./legacy');
|
||||
const _shades_classic = require('./shades-classic');
|
||||
const _shades_grey = require('./shades-grey');
|
||||
const _rect = require('./rect');
|
||||
|
||||
module.exports = {
|
||||
legacy: _legacy,
|
||||
shades_classic: _shades_classic,
|
||||
shades_grey: _shades_grey,
|
||||
rect: _rect
|
||||
};
|
6
node_modules/cli-progress/presets/legacy.js
generated
vendored
Normal file
6
node_modules/cli-progress/presets/legacy.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// cli-progress legacy style as of 1.x
|
||||
module.exports = {
|
||||
format: 'progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}',
|
||||
barCompleteChar: '=',
|
||||
barIncompleteChar: '-'
|
||||
};
|
5
node_modules/cli-progress/presets/rect.js
generated
vendored
Normal file
5
node_modules/cli-progress/presets/rect.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
format: ' {bar}\u25A0 {percentage}% | ETA: {eta}s | {value}/{total}',
|
||||
barCompleteChar: '\u25A0',
|
||||
barIncompleteChar: ' '
|
||||
};
|
6
node_modules/cli-progress/presets/shades-classic.js
generated
vendored
Normal file
6
node_modules/cli-progress/presets/shades-classic.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// cli-progress legacy style as of 1.x
|
||||
module.exports = {
|
||||
format: ' {bar} {percentage}% | ETA: {eta}s | {value}/{total}',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591'
|
||||
};
|
8
node_modules/cli-progress/presets/shades-grey.js
generated
vendored
Normal file
8
node_modules/cli-progress/presets/shades-grey.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
const _colors = require('colors');
|
||||
|
||||
// cli-progress legacy style as of 1.x
|
||||
module.exports = {
|
||||
format: _colors.grey(' {bar}') + ' {percentage}% | ETA: {eta}s | {value}/{total}',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591'
|
||||
};
|
Reference in New Issue
Block a user