Skip to content

cli: add progress bar for doc generation#885

Open
InukaWijerathna wants to merge 1 commit into
nodejs:mainfrom
InukaWijerathna:cli-progress-bar
Open

cli: add progress bar for doc generation#885
InukaWijerathna wants to merge 1 commit into
nodejs:mainfrom
InukaWijerathna:cli-progress-bar

Conversation

@InukaWijerathna

Copy link
Copy Markdown

Summary

Adds a cli-progress-based progress bar that tracks how many of the requested generators have completed while generate runs, similar to the approach used in nodejs.dev's getApiDocsData.js referenced in the issue.

  • New src/utils/progress-bar.mjs wraps a cli-progress SingleBar. Rendering is skipped entirely when stdout isn't a TTY, so CI logs, piped output, and tests never receive raw escape codes or bar frames.
  • runGenerators() now accepts an optional { onGeneratorComplete } callback, invoked once per requested target (not its dependencies) as soon as its result is ready.
  • The generate command creates the bar, starts it with the target count, and wires onGeneratorComplete to increment.

Test plan

  • New unit tests for progress-bar.mjs (mocks cli-progress to verify correct start/increment/stop calls, and that it's a no-op off-TTY)
  • New test in generators.test.mjs asserting onGeneratorComplete fires once per requested target, not per dependency
  • Forced process.stdout.isTTY = true manually and drove a real SingleBar instance through the exported API to confirm no runtime errors
  • npm test — no new failures (3 pre-existing failures on this checkout are unrelated Windows path-separator issues, reproducible on main)
  • npm run lint — clean (pre-existing unrelated warnings only)

Closes #58

Adds a cli-progress-based progress bar (src/utils/progress-bar.mjs)
that tracks how many of the requested generators have completed while
`generate` runs. Rendering is skipped when stdout isn't a TTY so CI
logs and piped output stay clean.

runGenerators() now accepts an optional onGeneratorComplete callback,
invoked once per requested target as its result becomes ready, which
the generate command wires up to the progress bar.

Refs: nodejs#58
@InukaWijerathna InukaWijerathna requested a review from a team as a code owner July 5, 2026 17:19
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Jul 5, 2026 5:19pm

Request Review

@cursor

cursor Bot commented Jul 5, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
CLI UX and an optional callback on the generator runner; no auth, data, or core generation logic changes.

Overview
The generate command now shows a CLI progress bar while the generator pipeline runs, so users can see how many of the requested targets have finished.

A new createProgressBar helper (backed by cli-progress) renders a SingleBar only when stdout is a TTY; otherwise it returns no-op start / increment / stop so CI, pipes, and tests avoid escape codes.

runGenerators accepts an optional onGeneratorComplete callback, fired once per requested target (not dependency-only generators) when that target’s result is ready; the command starts the bar with config.target.length and wires increment to that callback.

Tests cover the progress bar behavior (TTY vs non-TTY) and that onGeneratorComplete is not invoked for dependency-only runs.

Reviewed by Cursor Bugbot for commit 4d7db68. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4d7db68. Configure here.

Comment thread bin/commands/generate.mjs
onGeneratorComplete: progressBar.increment,
});

progressBar.stop();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Progress bar not stopped on failure

Medium Severity

When runGenerators rejects, progressBar.stop() is skipped because it runs only after a successful await. The TTY bar is started with hideCursor: true, so a failed generate can leave the terminal cursor hidden until the user resets the shell.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4d7db68. Configure here.

@avivkeller avivkeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate of #680

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cli-progress (Progress Bar) for CLI

2 participants