Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: Unnecessary package name truncation in upgrade-interactive #5723

Open
1 task
wincent opened this issue Sep 9, 2023 · 6 comments
Open
1 task

[Bug?]: Unnecessary package name truncation in upgrade-interactive #5723

wincent opened this issue Sep 9, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@wincent
Copy link
Contributor

wincent commented Sep 9, 2023

Self-service

  • I'd be willing to implement a fix

Describe the bug

Package names seem to be unnecessarily truncated when using yarn upgrade-interactive on a narrow terminal — for example, see jes instead of jest, graphq instead of graphql etc:

 Press <up>/<down> to select packages.            Press <enter> to install.
 Press <up>/<down> to select packages.            Press <enter> to install.
 Press <left>/<right> to select versions.         Press <ctrl+c> to abort.

? Pick the packages you want to upgrade.    Current        Range          Latest

   @jest/globa -----------------------------◉  ------------ ◯ ^29.6. ------
   @types/no -------------------------------◉  ------------ ◯ ^20.6. ------
 > graphq ----------------------------------◉  ------------ ◯ ^16.8. ------
   jest-conf -------------------------------◉  ------------ ◯ ^29.6. ------
   jes -------------------------------------◉  ------------ ◯ ^29.6. ------
   prettier-v2-for-jest-inline-snaps -------◉ npm:prettie…  ◯ ^2.8. -------
   prettie ---------------------------------◉  ------------ ◯ ^3.0. -------
   ts-jes ----------------------------------◉  ------------ ◯ ^29.1. ------
   typescri --------------------------------◉  ------------ ◯ ^5.2. -------

To reproduce

Run yarn upgrade-interactive in a narrow terminal window. Not sure if a very wide package name is needed to make this manifest (see prettier-v2-for-jest-inline-snapshots in the example above).

Environment

  System:
    OS: macOS 12.6.8
    CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
  Binaries:
    Node: 18.0.0 - /private/var/folders/tl/04jnvr4s34v704k5h2rqjmkh0000gn/T/xfs-814df800/node
    Yarn: 3.6.3 - /private/var/folders/tl/04jnvr4s34v704k5h2rqjmkh0000gn/T/xfs-814df800/yarn
    npm: 8.6.0 - ~/n/bin/npm
  npmPackages:
    jest: * => 29.6.4 

Additional context

No response

@wincent wincent added the bug Something isn't working label Sep 9, 2023
@wincent
Copy link
Contributor Author

wincent commented Sep 12, 2023

Truncation of output in macOS is governed by system builtin terminal

I'm not familiar with that builtin. Do you have a link?

I'm a bit surprised that in the example above where the first column has been allocated a width of 41 characters, this builtin would somehow choose to render:

  • prettier-v2-for-jest-inline-snapshots" as "prettier-v2-for-jest-inline-snaps (ie. cutting off 4 characters)
  • jest as jes (ie. cutting off 1 character)
  • @types/node as @types/no (ie. cutting off 2 characters)
  • typescript as typescri (ie. cutting off 2 characters).
  • etc

There seems to be no rhyme or reason to it. Are you claiming this isn't a Yarn bug?

@arcanis
Copy link
Member

arcanis commented Sep 12, 2023

I somewhat suspect that the code truncating the columns when the content is larger isn't taking the ansi codes into account when computing the slice 🤔 Unfortunately it seems to come from ink, we don't do the truncation ourselves.

@cakoose
Copy link
Contributor

cakoose commented Dec 3, 2023

The behavior at different sizes is kind of interesting to see (iTerm2 on MacOS):

Screen.Recording.2023-12-03.at.12.35.09.mov
  • MacOS: 14.1.1
  • iTerm2: 3.4.22
  • Yarn 4.0.1
  • Node: 18.18.2

@cakoose
Copy link
Contributor

cakoose commented Dec 3, 2023

@arcanis: I noticed that Yarn uses ink to format the table but uses chalk to format the text inside the table.

What I think might be happening:

  1. Yarn uses chalk to colorize the package name, yielding a string with terminal escape sequences.
  2. Yarn passes that string to ink to render inside the table. ink treats it like a regular string, which results in the the rendering artifacts: gaps in the string, early truncation, etc.

Maybe things will work better if Yarn stops using two separate libraries and just uses ink? (ink is capable of colorizing text.)

Tangent: There's an enhancement request on ink (link) to detect embedded terminal escape sequences. That seems like a hack to me; it feels out of scope for ink to be parsing escape sequences at all, let alone escape sequences produced by another tool. But it would be convenient!

@Reeywhaar
Copy link

Reeywhaar commented Dec 11, 2023

Same for me 🤦‍♂️

image

Why deprecate yarn outdated and replace it with half-baked overengineered thing...

@felixgeissler
Copy link

I can reproduce the same issue. It did work as expected until I updated from 4.1.0 -> 4.1.1. Now even a downgrade won't fix it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants