-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Windows log fixes #1307
Windows log fixes #1307
Conversation
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
For me, it's ok. |
Not sure I agree with the proposed solution for windows. This seems to be a problem with cmd.exe not supporting unicode by default. I guess this change would affect anybody on windows, regardless of which shell they use. |
In my original patch I used figures. But being that here they don't use chalk either, I just kept the original patch @AdrianoCahete had made. I'm not sure what you mean by abstracted. If you mean have the common code in one place, that would make sense. On the other hand, I don't see why should reinvent the wheel and not just use figures and chalk for colors. Anyway, the fact is that this works with the default shell Windows comes with and thus fixes the issue I reported. |
@Janpot: Also, the CC here was for you to confirm you allow the use of your patch, which you didn't. |
I have to agree with @Janpot that abstraction would be a better way to deal with this. |
Yep, I mentioned |
I would wait for @paulirish, @patrickhulce or @brendankenny to give the final judgement :) @XhmikosR Thanks for this pr but as janpot says it are 2 seperates issues. You should fix unicode issues in this PR :) |
Cygwin seems to don't show unicode by default. |
Since the other committers are ok with the cherry pick, I think we can move forward with this one. I'm going to close #1272 to focus efforts here. In the future, we'd prefer if individual PRs fix individual issues. This one is getting a bit hard to follow because of the cherry picking and multiple issues that are being referenced. |
@@ -191,7 +191,11 @@ class ChromeLauncher { | |||
launcher | |||
.isDebuggerReady() | |||
.then(() => { | |||
log.log('ChromeLauncher', waitStatus + `${green}✓${reset}`); | |||
if (process.platform === 'win32') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about:
// See https://github.com/GoogleChrome/lighthouse/issues/1228
const check = process.platform === 'win32' ? '\u221A' : '✓';
log.log('ChromeLauncher', waitStatus + `${green}${check}${reset}`);`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me, I'll change it to that.
@@ -56,8 +56,8 @@ function formatAggregationResultItem(score: boolean | number | string, suffix?: | |||
const reset = '\x1B[0m'; | |||
|
|||
if (typeof score === 'boolean') { | |||
const check = `${green}✓${reset}`; | |||
const fail = `${red}✘${reset}`; | |||
const check = process.platform === 'win32' ? `${green}\u221A${reset}` : `${green}✓${reset}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar suggestion
@@ -97,7 +97,11 @@ function createOutput(results: Results, outputMode: OutputMode): string { | |||
let output = `\n\n${bold}Lighthouse (${version}) results:${reset} ${results.url}\n\n`; | |||
|
|||
results.aggregations.forEach(aggregation => { | |||
output += `▫ ${bold}${aggregation.name}${reset}\n\n`; | |||
if (process.platform === 'win32') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar suggestion to dry this up.
@@ -148,7 +148,11 @@ class CriticalRequestChains extends Formatter { | |||
|
|||
// If the parent is the last child then don't drop the vertical bar. | |||
const ancestorTreeMarker = treeMarkers.reduce((markers, marker) => { | |||
return markers + (marker ? '┃ ' : ' '); | |||
if (process.platform === 'win32') { | |||
return markers + (marker ? '\u2502 ' : ' '); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@wardpeet: I don't use cygwin so I can't test there. MSYS works fine on my test VM. Now some things to note:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more small things.
return markers + (marker ? '┃ ' : ' '); | ||
// See https://github.com/GoogleChrome/lighthouse/issues/1228 | ||
const sym = process.platform === 'win32' ? '\u2502 ' : '┃ '; | ||
return markers + (marker ? sym : ' '); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is funky here.
let treeMarker = ancestorTreeMarker; | ||
if (process.platform === 'win32') { | ||
treeMarker += (isLastChild ? '\u2514\u2500' : '\u251C\u2500') + | ||
(hasChildren ? '\u252C' : '\u2500'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 space indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be 4 space indentation? I don't see this being enforced by ESLint ;/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. We do it elsewhere, but sadly, I don't think there's a rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine as a 2-space indentation. I added the rule locally to ESLint and it's passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine as a 2-space indentation
definitely needs a four space indent after a continuation like this :)
Happy to have a rule to enforce that...may just be the eslint config didn't bring that over when we updated it recently.
treeMarker += (isLastChild ? '\u2514\u2500' : '\u251C\u2500') + | ||
(hasChildren ? '\u252C' : '\u2500'); | ||
} else { | ||
treeMarker += (isLastChild ? '┗━' : '┣━') + | ||
(hasChildren ? '┳' : '━'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 space indent
Can you also look into the failing tests? |
@ebidel: the tests failure is due to the expired SSL certificate
|
Derp, thanks for the heads up on the ssl cert. I'll tell the Polymer team. Can you file an issue for the remaining items? |
Which issues? We mentioned many things here :p |
#1307 (comment) and anything else this PR doesn't currently cover :) |
All right, I'll try to wrap everything up and make a couple of issues next year :) |
@@ -191,7 +191,9 @@ class ChromeLauncher { | |||
launcher | |||
.isDebuggerReady() | |||
.then(() => { | |||
log.log('ChromeLauncher', waitStatus + `${green}✓${reset}`); | |||
// See https://github.com/GoogleChrome/lighthouse/issues/1228 | |||
const check = process.platform === 'win32' ? '\u221A' : '✓'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you pull this into a file-level global a la green
and reset
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean along with green
and reset
at the top of the file?
const check = `${green}✓${reset}`; | ||
const fail = `${red}✘${reset}`; | ||
// See https://github.com/GoogleChrome/lighthouse/issues/1228 | ||
const check = process.platform === 'win32' ? `${green}\u221A${reset}` : `${green}✓${reset}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
globals here too
(hasChildren ? '┳' : '━'); | ||
let treeMarker = ancestorTreeMarker; | ||
if (process.platform === 'win32') { | ||
treeMarker += (isLastChild ? '\u2514\u2500' : '\u251C\u2500') + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe do this as with ancestorTreeMarker
above, where the symbol is picked conditionally (maybe at file level) but all platforms construct the string in the same way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind doing this, I"m just having trouble naming those symbols :/
@@ -148,7 +148,9 @@ class CriticalRequestChains extends Formatter { | |||
|
|||
// If the parent is the last child then don't drop the vertical bar. | |||
const ancestorTreeMarker = treeMarkers.reduce((markers, marker) => { | |||
return markers + (marker ? '┃ ' : ' '); | |||
// See https://github.com/GoogleChrome/lighthouse/issues/1228 | |||
const sym = process.platform === 'win32' ? '\u2502 ' : '┃ '; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file-level consts for these may work better, too.
const debugNode = require('debug/node'); | ||
debugNode.colors = [colors.cyan, colors.green, colors.blue, colors.magenta]; | ||
} | ||
debug.colors = [colors.cyan, colors.green, colors.blue, colors.magenta]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this play along with the changes @paulirish was making in #915? We don't want to regress the browserified build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another option is to lock the package.json
version to debug
2.2.0 as our yarn.lock
file does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR shouldn't affect anything else other than Windows console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah this simplification shoulda been in 915. lgtm
Confirming the smokehouse tests pass if you remove shop. |
@brendankenny @ebidel: please check now and let me know. Ah, I found where I saw this https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-cli/test/smokehouse/smokehouse.js#L36 So, ideally, after this PR goes in, all common related stuff should go into the same file to prevent WET. |
const debugNode = require('debug/node'); | ||
debugNode.colors = [colors.cyan, colors.green, colors.blue, colors.magenta]; | ||
} | ||
debug.colors = [colors.cyan, colors.green, colors.blue, colors.magenta]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah this simplification shoulda been in 915. lgtm
const reset = '\x1B[0m'; | ||
|
||
// See https://github.com/GoogleChrome/lighthouse/issues/1228 | ||
const tick = process.platform === 'win32' ? '\u221A' : '✓'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we simplify and just always use the unicode escape, and never the literal?
const tick = '\u221A'; // ✓
(I'm assuming the windows character in play is the exact same as the literal... that right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like they're different. ✓ vs √
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay. then we'll stick with this hilarity.
Let's pull process.platform === 'win32'
out into a isWindows
boolean then
@XhmikosR , sg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, unfortunately, the normal tick is bold and looks a lot better on normal terminals, i.e. not Windows :/
I'll add the const
now and this can be refactored later, see #1307 (comment)
@paulirish just want to point out it's not just a simplification. |
browserify selects correct file automatically. Also `log.color = undefined` causes problems.
Seriously great group effort on this. Thanks all! |
This is #1272 cherry picked, #1305 cherry picked and fixed.
Verified everything works on my Windows VM.
Closes #1272, closes #1305.
Fixes #1228, fixes #1261.
Note to maintainers: Do not squash the branch when merging in order to keep author information.
Oh, and merry Christmas 🎄
/CC @Janpot to confirm you are OK with cherry picking your patch and close 1272.