Auto-install Playwright when not in consumer project#49
Merged
DeDuckProject merged 2 commits intomainfrom Mar 15, 2026
Merged
Conversation
Most projects integrating git-glimpse won't have @playwright/test as a dependency (e.g. game/backend projects). The action previously relied on the consumer's node_modules, failing with ERESOLVE for those projects. Adds ensurePlaywright() in packages/core/src/recorder/ensure-playwright.ts: - First tries to resolve @playwright/test from the consumer's project (preserving existing behaviour for projects that already have it pinned) - Falls back to auto-installing @playwright/test into ~/.cache/git-glimpse/playwright - Also ensures Chromium browser binaries are installed via playwright CLI Both playwright-runner.ts and fallback.ts now use ensurePlaywright() instead of a bare createRequire(process.cwd()) call. https://claude.ai/code/session_01XDxRzi588C73zsj1xPwmEb
Tests cover: consumer resolution (fast path), auto-install when missing, skip-install when cached, and Chromium browser installation. Also adds a note to CLAUDE.md that features/fixes should include unit tests. https://claude.ai/code/session_01XDxRzi588C73zsj1xPwmEb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactored Playwright resolution to automatically install
@playwright/testand Chromium browser binaries when they're not available in the consumer project. This enables git-glimpse to work in projects without existing Playwright setup.Key Changes
New module
ensure-playwright.ts: Extracted Playwright resolution logic into a dedicated module that:@playwright/testfrom the consumer's project (respecting their pinned version)~/.cache/git-glimpse/playwrightif not foundUpdated
playwright-runner.ts: Replaced directcreateRequirecall withensurePlaywright()to leverage the new auto-install logicUpdated
fallback.ts: Replaced directcreateRequirecall withensurePlaywright()for consistencyImproved error handling in
resolve-base-url.ts: EnhancedresolveBaseUrl()function to return structured error objects instead of null, providing clearer error messages when preview URL configuration is invalidUpdated action entry point: Integrated the new
resolveBaseUrl()function with proper error reportingImplementation Details
node_modulesto respect their dependency versions~/.cache/git-glimpse/playwrightwith fallback to system temp directoryms-playwrightcache to avoid redundant installationshttps://claude.ai/code/session_01XDxRzi588C73zsj1xPwmEb