Skip to content

feat(cli): add progress bar to generation pipeline#680

Open
shivxmsharma wants to merge 1 commit intonodejs:mainfrom
shivxmsharma:feat/cli-progress-bar
Open

feat(cli): add progress bar to generation pipeline#680
shivxmsharma wants to merge 1 commit intonodejs:mainfrom
shivxmsharma:feat/cli-progress-bar

Conversation

@shivxmsharma
Copy link
Contributor

Description

Adds a cli-progress progress bar to the generate command that tracks each target generator as it completes.

  • New src/utils/progressBar.mjs utility wraps cli-progress and writes to stderr to avoid conflicts with the existing logger (stdout)
  • Automatically disabled when stderr is not a TTY (CI environments, piped output)
  • New --no-progress flag to explicitly disable it

The bar starts after all generators are scheduled and increments once per target generator as its result collection finishes. The phase label shows the generator name:

  legacy-json [████████████████████████████████████████] 100% | 1/1

Validation

# Bar renders
node bin/cli.mjs generate -i "doc/api/*.md" -t legacy-json -o out -v 18.0.0

# Bar suppressed explicitly
node bin/cli.mjs generate -i "doc/api/*.md" -t legacy-json -o out -v 18.0.0 --no-progress

# Bar auto-suppressed in CI / piped output (stderr is not a TTY)
node bin/cli.mjs generate -i "doc/api/*.md" -t legacy-json -o out -v 18.0.0 2>/dev/null

All 312 existing tests pass.

Related Issues

Closes #58

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run npm run format to ensure the code follows the style guide.
  • I have run npm test to check if all tests are passing.

@shivxmsharma shivxmsharma requested a review from a team as a code owner March 15, 2026 17:24
Copilot AI review requested due to automatic review settings March 15, 2026 17:24
@vercel
Copy link

vercel bot commented Mar 15, 2026

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

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Mar 15, 2026 5:33pm

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional CLI progress bar to the generation pipeline so users can see per-target generator completion while running doc-kit generate.

Changes:

  • Introduces src/utils/progressBar.mjs, a small wrapper around cli-progress that renders to stderr and auto-disables when stderr isn’t a TTY.
  • Hooks the progress bar into src/generators.mjs so it starts after scheduling and increments once each target generator’s result collection finishes.
  • Adds --no-progress to the generate command and wires it into runGenerators, plus adds the cli-progress dependency.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/utils/progressBar.mjs New utility to create a TTY-aware progress bar that writes to stderr.
src/generators.mjs Starts/increments/stops the progress bar around target result collection.
bin/commands/generate.mjs Adds --no-progress and passes opts.progress into the generator runner.
package.json Adds cli-progress dependency.
package-lock.json Locks cli-progress and its transitive dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

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

cc @ovflowd given that the tooling is really fast, is a progress bar still needed?

errorWrap(async opts => {
const config = await setConfig(opts);
await runGenerators(config);
await runGenerators(config, opts.progress);
Copy link
Member

Choose a reason for hiding this comment

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

The progress bar should be a part of global config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I wait for @ovflowd's response or make the possible changes to this?

Copy link
Member

Choose a reason for hiding this comment

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

IMO progress bar should be disabled/enabled behind cli arg since it's related to cli.

Comment on lines +36 to +43
return {
/** @param {number} total */
start: total => bar.start(total, 0, { phase: 'Starting...' }),
/** @param {string} phase */
increment: phase => bar.increment({ phase }),
/** @returns {void} */
stop: () => bar.stop(),
};
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't this just return bar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the relevant changes, please review!

@shivxmsharma shivxmsharma force-pushed the feat/cli-progress-bar branch from 4f07217 to 57a244e Compare March 15, 2026 19:27
@vercel
Copy link

vercel bot commented Mar 15, 2026

Deployment failed with the following error:

The provided GitHub repository does not contain the requested branch or commit reference. Please ensure the repository is not empty.

Copy link
Member

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

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

LGMT ! and IMO it's still a good thing to have progress bar

@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 8.16327% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.22%. Comparing base (38c58bc) to head (57a244e).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/utils/progressBar.mjs 0.00% 30 Missing ⚠️
src/generators.mjs 0.00% 13 Missing ⚠️
bin/commands/generate.mjs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #680      +/-   ##
==========================================
- Coverage   74.74%   74.22%   -0.52%     
==========================================
  Files         146      147       +1     
  Lines       13255    13393     +138     
  Branches      960      967       +7     
==========================================
+ Hits         9907     9941      +34     
- Misses       3342     3446     +104     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

4 participants