[go: nahoru, domu]

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

Wing Console errors don't support ASCII colors #6582

Closed
eladb opened this issue May 28, 2024 · 2 comments · Fixed by #6893
Closed

Wing Console errors don't support ASCII colors #6582

eladb opened this issue May 28, 2024 · 2 comments · Fixed by #6893
Assignees
Labels
🐛 bug Something isn't working 🛫 console Console

Comments

@eladb
Copy link
Contributor
eladb commented May 28, 2024

I tried this:

bring expect;

expect.equal(["en"], []);

This happened:

Failed to compile.

Error: Expected values to be strictly deep-equal:
�[32m+ actual�[39m �[31m- expected�[39m

�[32m+�[39m [
�[32m+�[39m   'en'
�[32m+�[39m ]
�[31m-�[39m []
   --> src/manager.test.w:15:1
   |   model: model,
   | );
   | 
15 | expect.equal(manager.allLanguages, []);
   | ^
at /Users/eladb/playground/believe-in-serverless/src/manager.test.w:15:1

I expected this:

To have ASCII colors!

Is there a workaround?

No response

Anything else?

No response

Wing Version

No response

Node.js Version

No response

Platform(s)

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
@eladb eladb added the 🐛 bug Something isn't working label May 28, 2024
@ainvoner ainvoner added the 🛫 console Console label May 29, 2024
@skyrpex skyrpex self-assigned this Jul 11, 2024
@skyrpex
Copy link
Contributor
skyrpex commented Jul 11, 2024

Saving this ChatGPT output for later :)


ASCII colors, often referred to as ANSI escape codes, are sequences used to control text formatting, including color, in terminal and console output. These codes are embedded within strings and are interpreted by the terminal to display text in different colors and styles.

Here's a brief explanation of how they work and how you can convert them into RGB colors:

ANSI Escape Codes for Colors

ANSI escape codes for colors generally follow this pattern:

  • \x1b or \e or ESC (Escape character)
  • [ (Opening bracket)
  • Followed by one or more numbers and a letter (like m for color)

For example, \x1b[31m sets the text color to red, and \x1b[39m resets it to the default color.

Common Color Codes

Here are some common ANSI color codes:

  • \x1b[30m - Black
  • \x1b[31m - Red
  • \x1b[32m - Green
  • \x1b[33m - Yellow
  • \x1b[34m - Blue
  • \x1b[35m - Magenta
  • \x1b[36m - Cyan
  • \x1b[37m - White
  • \x1b[39m - Default color

Converting ANSI Colors to RGB

While ANSI colors are not directly specified in RGB values, we can map them to approximate RGB values based on common terminal color schemes.

Here's a basic mapping of ANSI color codes to their RGB equivalents:

  • \x1b[30m - Black: #000000
  • \x1b[31m - Red: #FF0000
  • \x1b[32m - Green: #00FF00
  • \x1b[33m - Yellow: #FFFF00
  • \x1b[34m - Blue: #0000FF
  • \x1b[35m - Magenta: #FF00FF
  • \x1b[36m - Cyan: #00FFFF
  • \x1b[37m - White: #FFFFFF
  • \x1b[39m - Default color: terminal's default (varies)

Example Conversion

Let's take your output and convert it to RGB:

Error: Expected values to be strictly deep-equal:
�[32m+ actual�[39m �[31m- expected�[39m

�[32m+�[39m [
�[32m+�[39m   'en'
�[32m+�[39m ]
�[31m-�[39m []
   --> src/manager.test.w:15:1
   |   model: model,
   | );
   | 
15 | expect.equal(manager.allLanguages, []);
   | ^
at /Users/eladb/playground/believe-in-serverless/src/manager.test.w:15:1

Here’s what it would look like with the ANSI codes replaced by RGB values:

Error: Expected values to be strictly deep-equal:
<font color="#00FF00">+ actual</font> <font color="#FF0000">- expected</font>

<font color="#00FF00">+</font> [
<font color="#00FF00">+</font>   'en'
<font color="#00FF00">+</font> ]
<font color="#FF0000">-</font> []
   --> src/manager.test.w:15:1
   |   model: model,
   | );
   | 
15 | expect.equal(manager.allLanguages, []);
   | ^
at /Users/eladb/playground/believe-in-serverless/src/manager.test.w:15:1

This should give you a clearer idea of how ANSI escape codes are translated to RGB colors for display in a terminal.

skyrpex added a commit that referenced this issue Jul 11, 2024
This changeset adds support for ASCII colors, normally used in the terminal, to the Console's Blue Screen Of Death.

Fixes #6582.
@mergify mergify bot closed this as completed in #6893 Jul 12, 2024
@mergify mergify bot closed this as completed in 98a9766 Jul 12, 2024
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.77.9.

boyney123 pushed a commit that referenced this issue Jul 15, 2024
#6893)

This changeset adds support for ASCII colors, normally used in the terminal, to the Console's Blue Screen Of Death.

Also, enables tests for the `@wingconsole/ui` package and improves the experience of using the cursor to copy the Blue Screen Of Death's error message.

Fixes #6582.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🛫 console Console
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants