Skip to content

Remove tty-table dependency - #1390

Merged
Andarist merged 5 commits into
changesets:mainfrom
bluwy:remove-tty-table
Jun 24, 2024
Merged

Andarist merged 5 commits into
changesets:mainfrom
bluwy:remove-tty-table

Conversation

@bluwy

@bluwy bluwy commented Jun 23, 2024 •

Copy link
Copy Markdown
Member

The tty-table dependency is only used for changeset status --verbose. The dependency has a very big dependency graph of 115 transitive dependencies with many polyfill packages.

This PR re-implements a simpler table formatting manually to remove tty-table, as I can't find a similar table printing table that would suffice the current requirements. I don't think the large dependency footprint is worth keeping it around either.

The main difference is that this PR's implementation does not shrink the table on small console widths, but I think it's a fine tradeoff for now. The shrinking behaviour also sometimes cuts off package names and changeset paths.

Before:

image image

After:

Previous refactor of table form image image

*Now updated as a list display from #1390 (comment)

image

@changeset-bot

changeset-bot Bot commented Jun 23, 2024 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e063e58

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@changesets/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci

codesandbox-ci Bot commented Jun 23, 2024 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@codecov

codecov Bot commented Jun 23, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 80.99%. Comparing base (f295b3e) to head (e063e58).

Files Patch % Lines
packages/cli/src/commands/status/index.ts 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1390      +/-   ##
==========================================
+ Coverage   80.95%   80.99%   +0.03%     
==========================================
  Files          54       54              
  Lines        2211     2210       -1     
  Branches      652      657       +5     
==========================================
  Hits         1790     1790              
+ Misses        417      416       -1     
  Partials        4        4              

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

@bluwy

bluwy commented Jun 23, 2024

Copy link
Copy Markdown
Member Author

Looks like status/index.ts wasn't covered by tests before, so adding more lines here seem to caused more missing coverage. Should I add some sort of test to cover it?

@bluwy

bluwy commented Jun 24, 2024

Copy link
Copy Markdown
Member Author

I've discussed with @jakebailey and @benmccann of some alternative table libraries:

  • cli-table3 - tradeoffs:
    • No word wrapping for small console widths
    • No direct option for table indenting (can be workaround with string manipulation)
  • table-layout - tradeoffs:
    • Larger dependency graph, but there's a PR to slim it down
    • Has a limited set of styling options

Other libraries like console-table-printer seem to also share the same or more tradeoffs of the above two libraries. Or libraries like cliui could work but they're CLI focused.

@Andarist

Copy link
Copy Markdown
Member

In a sense, the only thing that --verbose does is print the information about related changesets. The table layout is kinda nice at presenting this but maybe it's unnecessary? Can we think about a different of presenting this data that would result in a simpler code and that wouldn't suffer from wrapping limitations/complexity?

@bluwy

bluwy commented Jun 24, 2024

Copy link
Copy Markdown
Member Author

Perhaps a list form like this?
image

A bit similar to non-verbose mode but with the added version and changeset files.

@Andarist

Copy link
Copy Markdown
Member

It works for me, I think. Since a lot of changesets can be related to any particular release, I wonder if this should be a bullet~ list or just a comma-delimited list. None of them is perfect as it all depends on how many packages, changesets, etc u have... Let's just roll with what u have above.

Comment thread .changeset/thirty-glasses-complain.md Resolved
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.

2 participants