npm / gauge Goto Github PK
View Code? Open in Web Editor NEWA terminal based horizontal guage aka, a progress bar
License: Other
A terminal based horizontal guage aka, a progress bar
License: Other
You can see a demo of the current theme for various levels of OS/unicode/color support here:
https://twitter.com/ReBeccaOrg/status/701336143686578176
Or try running demo.js
from the repo. 2.0, which has this is in beta. Right now changing this up is easy and cheap, so help me paint this bikeshed.
Hi Rebecca,
I was surprised to find that the latest npm release (2.6.0) contains temporary files :
-rw-rw-r-- 1 glorieux glorieux 395 Jun 16 03:59 base-theme.js
-rw-rw-r-- 1 glorieux glorieux 5.4K Jun 16 10:55 CHANGELOG.md
-rw-rw-r-- 1 glorieux glorieux 5.0K Jun 16 06:18 CHANGELOG.md~
-rw-rw-r-- 1 glorieux glorieux 616 Jun 16 03:59 error.js
-rw-rw-r-- 1 glorieux glorieux 292 Jun 16 03:59 has-color.js
-rw-rw-r-- 1 glorieux glorieux 6.7K Jun 16 10:52 index.js
-rw-rw-r-- 1 glorieux glorieux 751 Jan 25 2015 LICENSE
-rw-rw-r-- 1 glorieux glorieux 3.0K Jul 6 10:33 package.json
-rw-rw-r-- 1 glorieux glorieux 1.2K Jun 16 03:59 plumbing.js
-rw-rw-r-- 1 glorieux glorieux 89 Jun 16 03:59 process.js
-rw-rw-r-- 1 glorieux glorieux 998 Jun 16 03:59 progress-bar.js
-rw-rw-r-- 1 glorieux glorieux 15K Jun 16 10:53 README.md
-rw-rw-r-- 1 glorieux glorieux 15K Jun 16 06:12 README.md~
-rw-rw-r-- 1 glorieux glorieux 5.7K Jun 16 10:51 render-template.js
-rw-rw-r-- 1 glorieux glorieux 139 Jun 16 03:59 set-immediate.js
-rw-rw-r-- 1 glorieux glorieux 93 Jun 16 03:59 set-interval.js
-rw-rw-r-- 1 glorieux glorieux 105 Jun 16 03:59 spin.js
-rw-rw-r-- 1 glorieux glorieux 1.9K Jun 16 03:59 template-item.js
-rw-rw-r-- 1 glorieux glorieux 3.7K Jun 16 03:59 theme-set.js
-rw-rw-r-- 1 glorieux glorieux 1.6K Jun 16 03:59 themes.js
-rw-rw-r-- 1 glorieux glorieux 828 Jun 16 03:59 wide-truncate.js
Looks like leftovers from the release 😉
See sonatype-nexus-community/auditjs#64
I guess this is a bug in npm?
Hello!
I hope you are doing well!
We are a security research team. Our tool automatically detected a vulnerability in this repository. We want to disclose it responsibly. GitHub has a feature called Private vulnerability reporting, which enables security research to privately disclose a vulnerability. Unfortunately, it is not enabled for this repository.
Can you enable it, so that we can report it?
Thanks in advance!
PS: you can read about how to enable private vulnerability reporting here: https://docs.github.com/en/code-security/security-advisories/repository-security-advisories/configuring-private-vulnerability-reporting-for-a-repository
we started noticing these popping up when installing prebuild (prebuild/prebuild#87)
npm WARN deprecated [email protected]: This package has been renamed. Use lodash.padend@^4.0.0.
would be nice to get this fixed :)
Using CI
and CONTINUOUS_INTEGRATION
env vars. Some, such as Travis CI, simulate a TTY causing process.stdout.isTTY
to return true
.
The issue in npm/npm#9682 appears to be something to do with gauge AFAICT. The output of the npm command is correct, it just doesn't appear in the terminal because the line is erased. :(
I had a poke around but I'm unclear what the exact issue is.
Removing the this.cursor.horizontalAbsolute(0).eraseLine()
line from gauge's .hide
stops the last line from being erased (though output is understandably broken due to lingering gauges).
ProgressBar.prototype.hide = function() {
if (!isTTY()) return
if (this.disabled) return
this.cursor.show()
if (this.showing) this.cursor.up(1)
this.cursor.horizontalAbsolute(0).eraseLine() // remove this and the last line is not erased
this.showing = false
}
Perhaps it needs to do something like this? NFI though.
https://github.com/TooTallNate/ansi.js/blob/master/examples/progress/index.js#L38-L45
Would you be open to changing the default unicode theme to a more elegant spinner, like https://github.com/sindresorhus/elegant-spinner? The current implementation feels a bit crooked.
I'm not suggesting to introduce it as a dependency, as that would probably be too much effort.
Details are here: npm/npm#13274
UNCAUGHT EXCEPTION - keeping process alive: Error: Cannot find module 'object-assign'
Require stack:
"object-assign" should be added to package.json dependencies
Support window resize events
For a CLI project I'm currently engaged in, I looked closely at both gauge and https://github.com/tj/node-progress . I ended up opting for gauge, primarily because my project discovers more work to do as it progresses, which gauge handles perfectly.
However, I would like to eventually display an ETA to my users, especially as the workload stabilises fairly early within the process. Just not early enough to use progress instead.
Is this something that you think is within the scope of this project?
Or should we have some sort of extension mechanism first, and develop ETAs as a third-party extension?
The npm
package depends on cli-table3
, which uses string-width
and strip-ansi
in recent versions.
It also uses this gauge
package (through npmlog
) which uses older versions of string-width
and strip-ansi
. the wide-align
dependency also brings its own versions of string-width
and strip-ansi
, which are potentially different too.
Packages string-width
and strip-ansi
(and potentially others too, but I stopped analyzing the tree at some point) are installed many times in different versions
The dependencies should be updated to use recent versions, so that more deduplication can be done (and the maintenance status of older major version could be another reason to upgrade).
run in node 0.12.7,gives me:
/Users/zhengxingcheng/data/lab/gauge/index.js:88 if (theme && (Object.keys(theme).length === 0 || theme.hasUnicode != null || ^ TypeError: Object.keys called on non-object at Function.keys (native) at Object.Gauge._computeTheme (/Users/zhengxingcheng/data/lab/gauge/index.js:88:24) at Object.Gauge (/Users/zhengxingcheng/data/lab/gauge/index.js:51:20) at nextBar (/Users/zhengxingcheng/data/lab/gauge/demo.js:19:12) at Object.<anonymous> (/Users/zhengxingcheng/data/lab/gauge/demo.js:13:1) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10)
Currently: guage
The last release was a while ago.
Not sure what I might be doing wrong here, but I don't see it working as expected. Here's my code
var Gauge = require('gauge');
var async = require('async');
var gauge = new Gauge();
var n = 20;
gauge.show('Test', 0);
async.times(n, function (index, cb) {
gauge.pulse('run #' + index);
setTimeout(function () {
gauge.show(index, index / n);
}, 3000);
}, function (err, res) {
console.log('Done!');
});
Soo, any time I use it outside npmlog (which pulses on loglines only), I'm inevitably confused why just calling gauge.show
on changes doesn't make the spinner spin.
I'm now of the opinion that gauge.show
should increment the spinner just the way pulse does. This would make the two commands essentially identical, just having different short-cut type arguments– show
being section
and completed
, and pulse
be subsection
. It might be time to just eliminate pulse
entirely.
Would probably help with stuff like npm/npm#8826 (comment)
Would be really nice to separate from any logging.
When instantiating 10 or more gauges in the same process there are warnings from Nodejs core.
var G = require('gauge')
new G, new G, new G, new G, new G, new G, new G, new G, new G // first nine are okay
new G // tenth: resize
// > (node:71997) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 resize listeners added. Use emitter.setMaxListeners() to increase limit
new G // eleventh: exit
// > (node:71997) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
As a workaround:
gauge.disable()
(where gauge
is the instance of G
).{cleanupOnExit: false}
(your app should deal with the cleanup in SIGINT
).But, it would be nice if the library could manage this overhead. I might get around to digging deeper and create a PR. For now just wanted to record this issue in case anyone else (or future me) runs into the same problem.
It seems like progress bar theming isn't being properly selected when running commands like npm install
on Fedora 27. Regardless of whether I run npm set unicode=true
the theme always defaults to fallback
and not the nicer theme like is does on macOS. I've checked my locales and everything like LC_ALL and LC_CTYPE in addition to the terminal emulator have it set to UTF-8 or 'en_US.UTF-8'. I'm running npm version 5.6.0 and I believe that uses gauge version 2.7.4.
Docs suggest using themes by requiring "gauge/themes." This stopped working at some point and no indication as to what the change is. Could the readme/docs get updated or point to the correct way to use this feature?
Require the theme and customize
// progress.js
import Gauge from 'gauge';
export default class Progress extends Gauge {
constructor (options) {
super(options);
}
};
// test.js
import Progress from './progress';
let progress = new Progress('Parsing subjects', 0);
progress.show('test', 1);
➜ node test.js
/node_modules/gauge/progress-bar.js:174
values.startgroup = theme.startgroup
^
TypeError: Cannot read property 'startgroup' of undefined
at ProgressBar.renderTemplate (/node_modules/gauge/progress-bar.js:174:28)
at drawBar (/node_modules/gauge/progress-bar.js:160:27)
at ProgressBar.show (/node_modules/gauge/progress-bar.js:149:10)
at Progress.next (/tools/progress.js:28:8)
at Object.<anonymous> (/test.js:4:10)
at Module._compile (module.js:460:26)
at normalLoader (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
There's a Regular Expression Denial of Service vulnerability in the ansi-regex package in versions < 6.0.1: https://app.snyk.io/vuln/SNYK-JS-ANSIREGEX-1583908
Would it be possible to update gauge deps to use a patched version?
The dependencies from this package that use out of date versions that I see are:
[email protected] > [email protected] > [email protected]
[email protected] > [email protected]
Fix version is https://github.com/chalk/ansi-regex/releases/tag/v6.0.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.