Skip to content

Commit

Permalink
build: fix pnpm pptr postinstall (DIYgod#12450)
Browse files Browse the repository at this point in the history
* chore: fix chrome not found in jest

* chore: explicitly require deps for stealth plugin
  • Loading branch information
TonyRL authored May 5, 2023
1 parent 76d0a7d commit a0ea328
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@

"onCreateCommand": "sudo apt-get update && export DEBIAN_FRONTEND=noninteractive && sudo apt-get -y install --no-install-recommends ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libdbus-1-3 libexpat1 libgbm1 libglib2.0-0 libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 wget xdg-utils redis-server && sudo apt-get autoremove -y && sudo apt-get clean -y && sudo rm -rf /var/lib/apt/lists/*",

"updateContentCommand": "pnpm -i && pnpm -i -C docs",
"updateContentCommand": "pnpm i && pnpm i -C docs && pnpm rb",

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pnpm -i && pnpm -i -C docs",
"postCreateCommand": "pnpm i && pnpm i -C docs && pnpm rb",

// Disable auto start dev env since codespaces sometimes fails to attach to the terminal
// "postAttachCommand": {
// "app": "pnpm -i",
// "app": "pnpm i",
// // "docs": "pnpm run docs:dev"
// },

Expand Down
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# folders
.devcontainer
.github
.idea
Expand All @@ -11,13 +12,16 @@ coverage
docs
node_modules
test

# files
.codecov.yml
.dockerignore
.editorconfig
.env
.eslint*
.gitignore
.gitpod.yml
.markdownlint.jsonc
.prettier*
.(yarn|npm|nvm)rc
*.md
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
cache: 'pnpm'
- name: Install dependencies (pnpm)
run: pnpm i
- name: Run postinstall script for dependencies
run: pnpm rb
- name: Test all and generate coverage
run: pnpm run jest:coverage
env:
Expand Down Expand Up @@ -99,6 +101,8 @@ jobs:
cache: 'pnpm'
- name: Install dependencies (pnpm)
run: pnpm i
- name: Run postinstall script for dependencies
run: pnpm rb
- name: Install Chromium
if: ${{ matrix.chromium.dependency != '' }}
# 'chromium-browser' from Ubuntu APT repo is a dummy package. Its version (85.0.4183.83) means
Expand Down
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tasks:
sudo apt update
sudo apt install -y ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libdbus-1-3 libexpat1 libgbm1 libglib2.0-0 libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 wget xdg-util
sudo apt install -y redis-server
init: pnpm -i && pnpm -i -C docs
init: pnpm i && pnpm i -C docs && pnpm rb
- name: app
command: pnpm run dev
openMode: tab-after
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ RUN \
set -ex && \
export PUPPETEER_SKIP_DOWNLOAD=true && \
corepack enable pnpm && \
pnpm install --prod --frozen-lockfile
pnpm install --prod --frozen-lockfile && \
pnpm rb

# ---------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -100,7 +101,8 @@ RUN \
echo 'Downloading Chromium...' && \
unset PUPPETEER_SKIP_DOWNLOAD && \
corepack enable pnpm && \
pnpm add puppeteer@$(cat /app/.puppeteer_version) --save-prod ; \
pnpm add puppeteer@$(cat /app/.puppeteer_version) --save-prod && \
pnpm rb ; \
else \
mkdir -p /app/node_modules/.cache/puppeteer ; \
fi;
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = async (extraOptions = {}) => {
const { addExtra } = require('puppeteer-extra');
puppeteer = addExtra(puppeteer);

// workaround for vercel/nft #54 and #283
// workaround for vercel/nft #54, #283, #304
require('puppeteer-extra-plugin-stealth/evasions/chrome.app');
require('puppeteer-extra-plugin-stealth/evasions/chrome.csi');
require('puppeteer-extra-plugin-stealth/evasions/chrome.loadTimes');
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
"puppeteer": "20.1.0",
"puppeteer-extra": "3.3.6",
"puppeteer-extra-plugin-stealth": "2.11.2",
"puppeteer-extra-plugin-user-data-dir": "2.4.1",
"puppeteer-extra-plugin-user-preferences": "2.4.1",
"query-string": "7.1.3",
"rand-user-agent": "1.0.109",
"re2": "1.18.0",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a0ea328

Please sign in to comment.