-
Notifications
You must be signed in to change notification settings - Fork 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
feat(cli): add command to list installed browsers #35240
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree |
This comment has been minimized.
This comment has been minimized.
Test results for "tests 1"1 failed 3 flaky38784 passed, 808 skipped Merge workflow run. |
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.
Thank you for the PR! I left some higher-level comments for now.
@@ -199,6 +199,29 @@ Examples: | |||
- $ install chrome firefox | |||
Install custom browsers, supports ${suggestedBrowsersToInstall()}.`); | |||
|
|||
program | |||
.command('list') |
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 see that issues talks about npx playwright install --list
instead of npx playwright list
. Generally, we'd prefer everything about browsers to be under install/uninstall
.
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.
Sorry, that's my fault. I should have shared my thought process in the PR description.
Initially, I started implementing the --list
option. Then, I discovered that it is possible to list installations for all instances of Playwright, and I realized the --all
flag could be useful. I felt that adding --all
and --list
to the install command would be excessive, especially since --all
only works in combination with --list
.
That's why I decided to implement standalone command list
This approach also follows the same pattern as the remove command:
• npx playwright remove (--all)
• npx playwright list (--all)
If you still prefer --list and --all flags I can change it.
// All new applications have a marker file right away. | ||
(browserName !== 'firefox' && browserName !== 'chromium' && browserName !== 'webkit'); | ||
if (!shouldHaveMarkerFile || (await existsAsync(browserDirectoryToMarkerFilePath(usedBrowserPath)))) | ||
|
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.
Instead of copying pretty much half of this method, perhaps we can extract the "step 1" from this function into a separate one and reuse it?
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'm a bit lost. I extracted a part of the code that verifies the marker file into a standalone function _validateMarkerFile
. I did this to reuse the same code in the remove and list functions.
What do you mean by saying 'step 1'?
.action(async (options: { all?: boolean }) => { | ||
await registry.list(!!options.all).then(browsersInfo => { | ||
for (const info of browsersInfo) { | ||
const whichInstanceLog = ` (${info.currentInstance ? 'CURRENT' : 'OTHER'})`; |
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 kinda find CURRENT/OTHER
being very much in my face. Can we tone it down somehow? Perhaps not show "other" at all, because we print the target directory anyway, and only mark current as (current)
when --all
is not passed?
Add a new CLI command to list all browser installations managed by Playwright. Fixes #34183
This command shows browsers installed by the current Playwright instance
npx playwright list
To list browsers installed by all Playwright instances, use the
--all
flag:npx playwright list --all