GithubHelp home page GithubHelp logo

kamiyo / multi-progress-bars Goto Github PK

View Code? Open in Web Editor NEW
27.0 27.0 4.0 13.19 MB

A multi progress bar library for CLI, with support for indefinite task spinners

License: MIT License

JavaScript 1.54% TypeScript 98.46%

multi-progress-bars's People

Contributors

kamiyo avatar starpit avatar vyobukhov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

starpit vyobukhov

multi-progress-bars's Issues

with v4, webpack builds fail

Observed Error

[WEBPACK] ERROR in ./node_modules/multi-progress-bars/dist/multi-progress-bars.es.js 1:0
[WEBPACK] Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (1:0)

This is due to having a "type": "commonjs" in your top-level package.json: https://github.com/kamiyo/multi-progress-bars/blob/master/package.json#L13

Proposed Solution

I think it could be resolved in a way that "just works" with the default webpack behavior by renaming your dist/multi-progress-bars.es.js to instead use a .mjs extension (this would require two matching changes to the package.json).

Process is not terminated remains null after bar is finished and program terminated.

After terminating the process with Ctrl-C it does not actually close and timers continue to run in the background before erroring when trying to write to console.

This behaviour is not seen when disabling the progress bars and only requires a new instance of the MultiProgressBars class to be created. Its not affected by calling .close or .cleanup.

You can checkout the codebase I'm trying to use it in here: https://github.com/Inrixia/Floatplane-Downloader/tree/5dae0aa57be48cbb87bebc0bfa4f2c3fcad18eef

image

Import as ES Module fails

Right now with version 4.2.0, importing multi-progress-bars into a project using ES modules fails like this:

file:///....../node_modules/multi-progress-bars/dist/multi-progress-bars.mjs:1
import { green } from 'chalk';
         ^^^^^
SyntaxError: Named export 'green' not found. The requested module 'chalk' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'chalk';
const { green } = pkg;

It's caused by how the TypeScript transpiler optimize import statements if it compiles to an ES module, and how NodeJS treats CJS imports in said ES modules. The error message suggests a potential solution to the problem, but I'm not sure if the TypeScript transpiler could be configured to achieve these statements.

Related (yet not similar) issues are discussed here and here.

As a side note, the issue doesn't appear if dist/multi-progress-bars.cjs is imported instead. However, this workaround can't be used with the current multi-progress-bars release, as it defines an exports section in its package.json which masks direct access to the files in the dist/ folder. The workaround would require the exports to be modified.

TypeError: MultiProgressBars is not a constructor

I'm using mbp like this:

const MultiProgressBars = require('multi-progress-bars')
const mpb = new MultiProgressBars();

and getting the following error:

TypeError: MultiProgressBars is not a constructor

What's the proper way to instatiate a progress bar? Thank you!

Chalk problem

Line 1 in multi-progress-bars.mjs

import { green } from 'chalk';

throws exception

import { green } from 'chalk';
^^^^^
SyntaxError: Named export 'green' not found. The requested module 'chalk' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

I'm using node 16

so it should be

import chalk from 'chalk';
const { green } = chalk;

Setting percentage on addTask does not apply to bar

When creating a new bar using .addTask trying to set the percentage of the bar using

bar.addTask("/=== SUMMARY ===\\", { type: "percentage", percentage: 0.5 });

for example the percentage is not set.
I have to call bar.update(...) to set it.

Crash when using pattern: '' for footer

When using a pattern of '' (empty string) a crash occours.
Example:

this.mpb?.setFooter({
  message: `\n\n${processed}\n${downloaded}\n${speed}`,
  pattern: '',
})
C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\node_modules\multi-progress-bars\dist\multi-progress-bars.cjs:421
        const base = clampString(pattern.repeat(Math.ceil(this.logger.width / stringWidth__default['default'](pattern))), this.logger.width);
                                         ^

RangeError: Invalid count value
    at String.repeat (<anonymous>)
    at MultiProgressBars.makeBorder (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\node_modules\multi-progress-bars\dist\multi-progress-bars.cjs:421:42)
    at MultiProgressBars.setFooter (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\node_modules\multi-progress-bars\dist\multi-progress-bars.cjs:472:50)
    at Downloader.updateSummaryBar (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\dist\Downloader.js:69:19)
    at Request.<anonymous> (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\dist\Downloader.js:137:34)
    at Request.emit (node:events:390:28)
    at IncomingMessage.<anonymous> (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\node_modules\floatplane\node_modules\got\dist\source\core\index.js:800:18)
    at Object.onceWrapper (node:events:509:28)
    at IncomingMessage.emit (node:events:402:35)
    at IncomingMessage.origin.emit (C:\Users\Inrix\git\Inrixia\Floatplane-Downloader\node_modules\floatplane\node_modules\@szmarczak\http-timer\dist\source\index.js:43:20)

somehow ffmpeg permanently hangs when attempting to finalize a video that already exists but wasn't detected/skipped

Not sure what causes it to happen, but it will start to download a video and go through the entire process, then freeze when doing the ffmpeg info. It's somehow not detecting an already downloaded video and re-downloading it (guessing the size changed or something?), but because the name already exists, it can't finish the process so it just sits there forever.

https://cdn.discordapp.com/attachments/468977376794247199/841765883276820480/unknown.png One screenshot showing somebody else having the issue. Band-aid solution is to close the program, and delete both the original.mp4 and the new blank extension file and make it redownload the whole thing once more.

when stream=process.stderr and stdout is not a TTY, the MPB UI does not update-in-place, and has no colors

If you update examples/exampleBottom.ts to add stream: process.stderr to the new MultiProgressBar() constructor, and then run this example in a situation where stdout is not a TTY, e.g.

node bottomInput.js > /dev/null

then the MultiProgressBar UI does not update in place. Instead every increment/update call results in the console scrolling. There seems to be some garbage "aN;H" added to every newline --- even though i expect no newlines.

Is it possible there a bug where the cursor control characters are always sent to stdout, even if stream is stderr? I haven't looked at your code yet to see.

Autonumber tasks and/or expose already added ones

Tasks don't seem to show up if I don't add an "index" value, but the tool itself could add an index and thus aleviate the need to account for the tasks added and coming up with a new index. A function exposing alrady added taks (bars) would also be apreciated and in turn this could be used to come up with a new index. Thanks.

Calling setFooter with newlines completely breaks output

Calling setFooter with a string that contains newlines results in massive console spam and loading bars completely breaking.
I presume this is due to the line counts being offset by the newlines.

Working:

this.mpb?.setFooter({
  message: `${processed} - ${downloaded} - ${speed}`,
  pattern: ' ',
});

Broken:

this.mpb?.setFooter({
  message: `${processed}\n${downloaded}\n${speed}`,
  pattern: ' ',
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.