diff --git a/README.md b/README.md index b3fbf68b..d633a78b 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,13 @@ Install the latest version of `e2ed` in devDependencies with the exact version: npm install e2ed --save-dev --save-exact ``` +Install [Playwright](https://playwright.dev/) [browsers](https://playwright.dev/docs/browsers) +(only `Chromium` for now): + +```sh +npx e2ed-install-browsers +``` + ### Initialize Initialize `e2ed` in the project; this will add an `autotests` directory diff --git a/scripts/writePrunedPackageJson.ts b/scripts/writePrunedPackageJson.ts index 301d956d..7042893d 100644 --- a/scripts/writePrunedPackageJson.ts +++ b/scripts/writePrunedPackageJson.ts @@ -5,14 +5,29 @@ import {writeFileSync} from 'node:fs'; import {join} from 'node:path'; -import originaPackageJson from '../package.json'; +import originalPackageJson from '../package.json'; + +type OriginalPackageJson = typeof originalPackageJson; + +type PrunedPackageJson = Omit & { + bin: OriginalPackageJson['bin'] & {['e2ed-install-browsers']: string}; + devDependencies: undefined; + scripts: undefined; +}; const prunedPackageJsonPath = join(__dirname, 'node_modules', 'e2ed', 'package.json'); -const prunedPackageJson: Partial = {...originaPackageJson}; +const playwrightVersion = originalPackageJson.dependencies['@playwright/test']; -delete prunedPackageJson.devDependencies; -delete prunedPackageJson.scripts; +const prunedPackageJson: PrunedPackageJson = { + ...originalPackageJson, + bin: { + ...originalPackageJson.bin, + 'e2ed-install-browsers': `npm install --global @playwright/browser-chromium@${playwrightVersion}`, + }, + devDependencies: undefined, + scripts: undefined, +}; const prunedPackageJsonText = JSON.stringify(prunedPackageJson, null, 2);