use playwright-firefox such that npm install does not download other browsers

This commit is contained in:
Ralf Vogler 2023-02-22 00:49:58 +01:00
parent 97f6735833
commit 18c27ba881
7 changed files with 31 additions and 30 deletions

View file

@ -7,10 +7,8 @@ FROM ubuntu:jammy
# https://github.com/hadolint/hadolint/wiki/DL4006
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG DEBIAN_FRONTEND=noninteractive
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD true
# Install up-to-date node & npm, deps for virtual screen & noVNC, browser, pip for apprise.
# Playwright needs --with-deps for firefox.
# Install up-to-date node & npm, deps for virtual screen & noVNC, firefox, pip for apprise.
RUN apt-get update \
&& apt-get install --no-install-recommends -y curl ca-certificates \
&& curl -fsSL https://deb.nodesource.com/setup_19.x | bash - \
@ -50,8 +48,11 @@ RUN pip install apprise
WORKDIR /fgc
COPY package*.json ./
# If firefox is installed (~/.cache/ms-playwright/firefox-*) before `npm install` it may be a newer version than in package.json and playwright will not find it; system deps are installed sep. via apt above to avoid having to pin the version there.
RUN npm install && npx playwright install firefox
# Playwright installs patched firefox to ~/.cache/ms-playwright/firefox-*
# Requires some system deps to run (see install-deps above).
RUN npm install
# Old: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD + install firefox (had to be done after `npm install` to get the correct version). Now: playwright-firefox as npm dep and `npm install` will only install that.
# RUN npx playwright install firefox
COPY . .

View file

@ -31,10 +31,10 @@ Data (including json files with claimed games, codes to redeem, screenshots) is
1. [Install Node.js](https://nodejs.org/en/download)
2. Clone/download this repository and `cd` into it in a terminal
3. Run `npm install && npx playwright install firefox`
3. Run `npm install`
4. Run `pip install apprise` to install [apprise](https://github.com/caronc/apprise) if you want notifications
This downloads Firefox to a cache in home ([doc](https://playwright.dev/docs/browsers#managing-browser-binaries)).
During `npm install` Playwright will download its Firefox to a cache in home ([doc](https://playwright.dev/docs/browsers#managing-browser-binaries)).
If you are missing some dependencies for the browser on your system, you can use `sudo npx playwright install firefox --with-deps`.
If you don't want to use Docker for quasi-headless mode, you could run inside a virtual machine, on a server, or you wake your PC at night to avoid being interrupted.

View file

@ -1,4 +1,4 @@
import { firefox } from 'playwright'; // stealth plugin needs no outdated playwright-extra
import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdated playwright-extra
import { authenticator } from 'otplib';
import path from 'path';
import { existsSync, writeFileSync } from 'fs';

2
gog.js
View file

@ -1,4 +1,4 @@
import { firefox } from 'playwright'; // stealth plugin needs no outdated playwright-extra
import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdated playwright-extra
import path from 'path';
import { jsonDb, datetime, filenamify, prompt, notify, html_game_list } from './util.js';
import { cfg } from './config.js';

38
package-lock.json generated
View file

@ -14,7 +14,7 @@
"enquirer": "^2.3.6",
"lowdb": "^5.1.0",
"otplib": "^12.0.1",
"playwright": "^1.31.0",
"playwright-firefox": "^1.31.0",
"puppeteer-extra-plugin-stealth": "^2.11.1"
}
},
@ -435,14 +435,10 @@
"node": ">=8"
}
},
"node_modules/playwright": {
"node_modules/playwright-core": {
"version": "1.31.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.31.0.tgz",
"integrity": "sha512-cFn1ie3bdYw/9/Ty3842CfPSRSy+ZWPjEhrxWgC+jL/CUjq5RKVJZwUbXV1UKBQU1Vo0NetsokXmk9EEZiqVHQ==",
"hasInstallScript": true,
"dependencies": {
"playwright-core": "1.31.0"
},
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.31.0.tgz",
"integrity": "sha512-/KquBjS5DcASCh8cGeNVHuC0kyb7c9plKTwaKxgOGtxT7+DZO2fjmFvPDBSXslEIK5CeOO/2kk5rOCktFXKEdA==",
"bin": {
"playwright": "cli.js"
},
@ -450,10 +446,14 @@
"node": ">=14"
}
},
"node_modules/playwright-core": {
"node_modules/playwright-firefox": {
"version": "1.31.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.31.0.tgz",
"integrity": "sha512-/KquBjS5DcASCh8cGeNVHuC0kyb7c9plKTwaKxgOGtxT7+DZO2fjmFvPDBSXslEIK5CeOO/2kk5rOCktFXKEdA==",
"resolved": "https://registry.npmjs.org/playwright-firefox/-/playwright-firefox-1.31.0.tgz",
"integrity": "sha512-E+v16LzBt6SaSRCLH0ZV8NuikTmbmbh9Ky1JgD5sCoF8OHJ3jEjtuoHAJCkO57PJhMX9q/oZ+x133seUMIsKzA==",
"hasInstallScript": true,
"dependencies": {
"playwright-core": "1.31.0"
},
"bin": {
"playwright": "cli.js"
},
@ -1002,19 +1002,19 @@
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="
},
"playwright": {
"version": "1.31.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.31.0.tgz",
"integrity": "sha512-cFn1ie3bdYw/9/Ty3842CfPSRSy+ZWPjEhrxWgC+jL/CUjq5RKVJZwUbXV1UKBQU1Vo0NetsokXmk9EEZiqVHQ==",
"requires": {
"playwright-core": "1.31.0"
}
},
"playwright-core": {
"version": "1.31.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.31.0.tgz",
"integrity": "sha512-/KquBjS5DcASCh8cGeNVHuC0kyb7c9plKTwaKxgOGtxT7+DZO2fjmFvPDBSXslEIK5CeOO/2kk5rOCktFXKEdA=="
},
"playwright-firefox": {
"version": "1.31.0",
"resolved": "https://registry.npmjs.org/playwright-firefox/-/playwright-firefox-1.31.0.tgz",
"integrity": "sha512-E+v16LzBt6SaSRCLH0ZV8NuikTmbmbh9Ky1JgD5sCoF8OHJ3jEjtuoHAJCkO57PJhMX9q/oZ+x133seUMIsKzA==",
"requires": {
"playwright-core": "1.31.0"
}
},
"puppeteer-extra-plugin": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/puppeteer-extra-plugin/-/puppeteer-extra-plugin-3.2.2.tgz",

View file

@ -15,7 +15,7 @@
"enquirer": "^2.3.6",
"lowdb": "^5.1.0",
"otplib": "^12.0.1",
"playwright": "^1.31.0",
"playwright-firefox": "^1.31.0",
"puppeteer-extra-plugin-stealth": "^2.11.1"
},
"repository": {

View file

@ -1,4 +1,4 @@
import { firefox } from 'playwright'; // stealth plugin needs no outdated playwright-extra
import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdated playwright-extra
import { authenticator } from 'otplib';
import path from 'path';
import { jsonDb, datetime, stealth, filenamify, prompt, notify, html_game_list } from './util.js';