Skip to content

Commit

Permalink
FI-1506 feat: add bin-command e2ed-install-browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
uid11 committed Nov 3, 2024
1 parent d15265c commit 058fb2a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 19 additions & 4 deletions scripts/writePrunedPackageJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<OriginalPackageJson, 'bin' | 'devDependencies' | 'scripts'> & {
bin: OriginalPackageJson['bin'] & {['e2ed-install-browsers']: string};
devDependencies: undefined;
scripts: undefined;
};

const prunedPackageJsonPath = join(__dirname, 'node_modules', 'e2ed', 'package.json');

const prunedPackageJson: Partial<typeof originaPackageJson> = {...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);

Expand Down

0 comments on commit 058fb2a

Please sign in to comment.