Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: Rewrite to automation-extra, Support both Playwright and Puppeteer #303

Closed
wants to merge 159 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
5d071b7
feat: Rewrite to automation-extra with Playwright support
berstend Aug 31, 2020
f64d833
feat: Add playwright-extra
berstend Aug 31, 2020
7d78b89
chore: Add additional tests
berstend Aug 31, 2020
531b4c5
chore(plugin-stealth): Update to new prettier style
berstend Aug 31, 2020
8f4a737
Chore: Update github workflow
berstend Aug 31, 2020
5d58d21
Chore: Update github workflow
berstend Aug 31, 2020
da3c61a
Chore: Update github workflow
berstend Aug 31, 2020
486c12a
Chore: Update github workflow
berstend Aug 31, 2020
61fb97a
Chore: Update github workflow
berstend Sep 1, 2020
110879c
Chore: Update github workflow
berstend Sep 1, 2020
a84d49d
chore(automation-extra): Update test
berstend Sep 1, 2020
736eba3
chore: Update to new prettier style
berstend Sep 1, 2020
bc97595
ci: Update tests
berstend Sep 1, 2020
ac4cfb8
lint(plugin-adblocker): Fix external dependency warning
berstend Sep 1, 2020
567e33d
ci: Update tests
berstend Sep 1, 2020
18dbce3
chore: Update github workflow
berstend Sep 1, 2020
f23958f
chore: Update github workflow
berstend Sep 1, 2020
dc9b64a
chore: Add testing-tools
berstend Sep 2, 2020
54b55a0
Merge branch 'master' into automation-extra
berstend Sep 30, 2020
a9b85f4
Merge branch 'master' into automation-extra
berstend Sep 30, 2020
93fdf2c
chore: Update yarn.lock
berstend Sep 30, 2020
f449dc7
chore: Fix build issue
berstend Sep 30, 2020
d282d35
chore: Fix build issue
berstend Sep 30, 2020
a6790ed
chore(plugin-anonymize-ua): Switch tests to use automation-extra
berstend Sep 30, 2020
0a24444
Merge branch 'master' into automation-extra
berstend Nov 15, 2020
4d4b2df
fix(plugin-stealth): Fix linting issue
berstend Nov 15, 2020
cb86e77
chore(testing-tools): Support 'all' stanza
berstend Nov 15, 2020
6ffbbec
fix(plugin-stealth): Don't assume options.arg exists already
berstend Nov 16, 2020
9fb0b89
chore: Update puppeteer devDependency to 5.4.1
berstend Nov 16, 2020
4b8c4e4
chore: Exclude old puppeteer-extra
berstend Nov 17, 2020
dc2d623
chore: Update tests and formatting
berstend Nov 17, 2020
136e6ba
feat: Make puppeteer-extra use the new automation-extra
berstend Nov 17, 2020
a400fb1
chore: Fix typo in comments
berstend Nov 17, 2020
7598274
Merge branch 'master' into automation-extra
berstend Nov 22, 2020
d06f3e7
feat: Improve testing, add shim support
berstend Nov 24, 2020
20dd27b
ci: Fix puppeteer firefox download
berstend Nov 24, 2020
cdc34c8
ci: Ignore old pptr versions when downloading FF
berstend Nov 24, 2020
2671602
ci: Bump pptr version to 5.5.0
berstend Nov 24, 2020
4f2b4a8
ci: Skip testing pptr firefox when not supported
berstend Nov 24, 2020
14e3fec
ci: Fix failing tests
berstend Nov 24, 2020
8995d5f
ci: Fix more failing tests
berstend Nov 24, 2020
8e605bb
ci: Fix more more failing tests
berstend Nov 24, 2020
ad12f19
ci: Finish up fixing failing tests
berstend Nov 24, 2020
48c3eae
feat: Replace merge-deep with deepmerge
berstend Nov 24, 2020
e53853f
chore: Update eslint
berstend Nov 24, 2020
634897c
feat: Use static id class property instead of name
berstend Nov 24, 2020
061e76c
chore: Update dependencies
berstend Nov 24, 2020
602d7ef
chore: Update rollup-plugin-typescript2
berstend Nov 24, 2020
c18e9cc
fix: Pin puppeteer-core version to prevent type mismatch
berstend Nov 24, 2020
0388848
ci: Fix linting issue
berstend Nov 24, 2020
1578f64
feat: Improve linting and tests
berstend Nov 25, 2020
55ebfb3
feat: Add recaptcha plugin with playwright support
berstend Nov 26, 2020
0a5aee1
chore: Bump Typescript and improve types
berstend Nov 26, 2020
2ec8675
chore: Update dev dependencies
berstend Nov 26, 2020
315e180
Merge branch 'master' into automation-extra
berstend Nov 26, 2020
bb0f620
feat(plugin-recaptcha): Add support for hCaptcha
berstend Nov 28, 2020
94e550e
ci: Fix linting issue
berstend Nov 28, 2020
f137379
docs: Update documentation
berstend Nov 28, 2020
35949a4
Merge branch 'master' into automation-extra
berstend Nov 28, 2020
aaba152
Merge branch 'master' into automation-extra
berstend Nov 28, 2020
3055b17
docs: Update documentation
berstend Nov 28, 2020
80496b5
docs: Update documentation
berstend Nov 28, 2020
aa49c09
feat: Simplify external type dependencies
berstend Nov 29, 2020
da8d164
chore: Update yarn.lock
berstend Nov 29, 2020
da4a2d2
chore(automation-extra): Update ava
berstend Nov 29, 2020
66e82c1
chore: Fix version numbers
berstend Nov 29, 2020
d23881f
chore(puppeteer-extra): Switch to typescript-eslint
berstend Nov 29, 2020
6913660
chore(puppeteer-extra): Update ava
berstend Nov 29, 2020
9bf2fa3
chore(automation-extra): Update rollup
berstend Nov 29, 2020
d173af3
chore(playwright-extra): Update dev dependencies
berstend Nov 29, 2020
d0cc14e
chore(automation-extra): Migrate to typescript-eslint
berstend Nov 29, 2020
3dd22d5
chore: Update documentation tooling
berstend Nov 30, 2020
2c1d9b4
docs: Update documentation
berstend Nov 30, 2020
1e11538
feat: Remove esModuleInterop from tsconfig
berstend Dec 1, 2020
01e4bd8
chore: Prettify prettierrc
berstend Dec 1, 2020
8d8a454
feat: Improve playwright product init
berstend Dec 1, 2020
26803a9
chore: Refactor module imports
berstend Dec 1, 2020
16a677a
chore: Exclude local testing directory
berstend Dec 2, 2020
b5344d3
docs: Update documentation
berstend Dec 2, 2020
0f58277
docs: Update documentation
berstend Dec 2, 2020
d7e1204
docs: Update documentation
berstend Dec 2, 2020
e4247ac
fix(plugin-recaptcha): Fix build process output
berstend Dec 3, 2020
7a9082f
chore: Update yarn.lock
berstend Dec 3, 2020
e2a4245
docs: Update documentation
berstend Dec 3, 2020
548d5eb
docs: Update documentation
berstend Dec 4, 2020
9583efb
feat(automation-extra-plugin): Add new plugins stanza
berstend Dec 5, 2020
60ab6c5
feat(automation-extra-plugin): Add new filter stanza
berstend Dec 5, 2020
973e489
feat(automation-extra): Add support for filter inheritance
berstend Dec 5, 2020
bcdf559
feat(automation-extra-plugin): Make plugin options type safe
berstend Dec 5, 2020
82e88c3
chore: Fix linting
berstend Dec 6, 2020
fe0a2c9
chore: Update gitignore
berstend Jan 12, 2021
de5a583
chore: Update yarn.lock
berstend Jan 12, 2021
4e77783
Merge branch 'master' into automation-extra
berstend Feb 4, 2021
6fc0ce1
Merge branch 'master' into automation-extra
berstend Feb 4, 2021
1d7a633
Merge branch 'master' into automation-extra
berstend Feb 6, 2021
90e789a
chore: Skip Puppeteer Firefox tests if not installed
berstend Feb 7, 2021
f7c42d4
chore: Update dependencies
berstend Feb 7, 2021
4bad9e6
Fix: Fire context events only once
berstend Feb 7, 2021
01c9cd0
chore: Bump playwright-core to 1.8.0
berstend Feb 7, 2021
8ec11bc
chore: Add gitignore exlclusion and fsevents hint
berstend Feb 7, 2021
94a343a
chore: Bump playwright to 1.8.0
berstend Feb 7, 2021
c58371c
feat(plugin-recaptcha): Backport recaptcha enterprise support
berstend Feb 7, 2021
fdae8b0
feat(plugin-user-preferences): Add tests
berstend Feb 7, 2021
5f6d959
chore: Update documentation
berstend Feb 7, 2021
34ec9e7
chore: Update documentation
berstend Feb 7, 2021
783a02c
chore: Update documentation
berstend Feb 7, 2021
1d014a7
chore: Update lerna
berstend Feb 7, 2021
82e8ebc
chore: Update lerna.json
berstend Feb 7, 2021
edeecd8
chore: Update lerna.json
berstend Feb 7, 2021
8fa4001
chore: Update package.json
berstend Feb 7, 2021
0dafb72
chore: Bump version
berstend Feb 7, 2021
18f47d6
chore: Bump version
berstend Feb 7, 2021
03bcc08
chore: Bump versions
berstend Feb 8, 2021
b071b3f
fix: Initialize empty options.arg array
berstend Feb 8, 2021
1025243
chore: Move requirement hints to debug log
berstend Feb 8, 2021
a6ed7c4
chore: Pin automation-extra-plugin version
berstend Feb 8, 2021
865dd4c
chore: Bump version
berstend Feb 8, 2021
4553c15
chore: Bump version
berstend Feb 8, 2021
35c62f3
chore: Bump version
berstend Feb 8, 2021
f18500f
docs: Update documentation
berstend Feb 8, 2021
4231cd6
docs: Update documentation
berstend Feb 8, 2021
e4838fe
docs: Update documentation
berstend Feb 8, 2021
52be410
chore: Refactor testing-tools to @extra-test/wrap
berstend Feb 8, 2021
a51f2c6
fix: Refactor testing-tools to @extra-test/wrap
berstend Feb 8, 2021
4ecd059
fix: Refactor testing-tools to @extra-test/wrap
berstend Feb 8, 2021
6e39c12
debug: Debug CI issues with @extra-test/wrap
berstend Feb 8, 2021
170a53a
debug: Debug CI issues with @extra-test/wrap
berstend Feb 8, 2021
4bca1f0
fix: Include @extra-test/wrap
berstend Feb 8, 2021
bed2607
chore: Update yarn.lock
berstend Feb 8, 2021
ad83752
ci: Add yarn build:helpers
berstend Feb 8, 2021
a232a47
ci: Fix yarn build:helpers
berstend Feb 8, 2021
13d19e8
ci: Fix yarn build:helpers
berstend Feb 8, 2021
0bad5c7
fix: Refactor @extra-test/wrap
berstend Feb 8, 2021
eb59cdb
chore: Update yarn.lock
berstend Feb 8, 2021
fc53b0c
fix: Refactor @extra-test/wrap
berstend Feb 8, 2021
ef100e3
chore: Clean up local tooling
berstend Feb 8, 2021
d9f78d9
chore: Update yarn.lock
berstend Feb 9, 2021
458b641
feat(plugin-humanize): Add @extra/humanize plugin
berstend Feb 9, 2021
b8a065d
chore(plugin-humanize): Enable publishing of scoped package
berstend Feb 9, 2021
0d63211
chore(plugin-humanize): Fix package and test quirk
berstend Feb 9, 2021
dbc1d01
chore: Cleanup
berstend Feb 9, 2021
846b2f2
chore: Cleanup
berstend Feb 9, 2021
37c7896
docs: Update documentation
berstend Feb 10, 2021
eeab010
chore(automation-extra-plugin): Use NestedPartial for plugin opts
berstend Feb 10, 2021
8fe5dec
chore: Make test more robust
berstend Feb 10, 2021
a5f9152
Merge branch 'master' into automation-extra
berstend Feb 13, 2021
f518b69
chore(automation-extra-plugin): Add type guard tests
berstend Feb 14, 2021
9103ec6
feat(automation-extra-plugin): Add CDP session shim
berstend Feb 14, 2021
8f9dcca
fix: Add devtools-protocol dependency
berstend Feb 14, 2021
9953c8d
fix: Make CDP test more robust
berstend Feb 14, 2021
be68ff9
feat(automation-extra-plugin): Add onWorkerCreated
berstend Feb 14, 2021
6480863
fix: Make test work with old pptr
berstend Feb 14, 2021
30b96c4
Merge branch 'master' into automation-extra
berstend Feb 16, 2021
0c3858b
feat(automation-extra): Add event emitter
berstend Feb 16, 2021
5b9a2b0
chore: Fix failing test
berstend Feb 16, 2021
5b070de
Update readme.md
berstend Mar 17, 2021
d5cb851
Update readme.md
berstend Mar 17, 2021
20e26f4
Update readme.md
berstend Mar 17, 2021
cb58607
Update readme.md
berstend Mar 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .eslintrc-ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
root: true,
extends: [
'standard-with-typescript',
'prettier',
'prettier/@typescript-eslint'
],
ignorePatterns: ['dist/*', 'node_modules/*'],
rules: {
'lines-between-class-members': ['off']
},
// Typescript specific rules would throw when used with .js files
overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
parserOptions: {
project: './tsconfig.eslint.json',
tsconfigRootDir: __dirname // https://github.com/typescript-eslint/typescript-eslint/issues/251
},
rules: {
'@typescript-eslint/strict-boolean-expressions': [
'warn',
{
allowNullableObject: true
}
],
'@typescript-eslint/lines-between-class-members': ['off'],
'@typescript-eslint/explicit-function-return-type': ['off']
}
}
]
}
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ on:
- 'test/*'

env:
CI: "true"
FORCE_COLOR: "true"
CI: 'true'
FORCE_COLOR: 'true'

jobs:
test:
Expand Down Expand Up @@ -77,9 +77,12 @@ jobs:
file node_modules/puppeteer-extra/dist/index.cjs.js
- uses: microsoft/playwright-github-action@v1

- name: download firefox (puppeteer)
run: yarn download-firefox

- name: test
uses: GabrielBB/xvfb-action@v1
env:
DISPLAY: ":99.0"
DISPLAY: ':99.0'
with:
run: yarn test-ci
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dist
.env.production.local
.cache
.rpt2_cache
.idea

lerna-debug.log*
lerna-error.log*
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ module.exports = {
...require('prettier-config-standard'),

// override for Windows
endOfLine: 'lf',
endOfLine: 'lf'
}
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# puppeteer-extra
# puppeteer-extra [![Downloads](https://img.shields.io/endpoint?style=social&url=https://runkit.io/fezvrasta/combined-npm-downloads/1.0.0?packages=puppeteer-extra,puppeteer-extra-plugin,puppeteer-extra-plugin-stealth,puppeteer-extra-plugin-recaptcha,puppeteer-extra-plugin-adblocker)](https://github.com/berstend/puppeteer-extra/)

This is the monorepo for [`puppeteer-extra`](./packages/puppeteer-extra), a modular plugin framework for [`puppeteer`](https://github.com/GoogleChrome/puppeteer). :-)
This is the monorepo for [`puppeteer-extra`](./packages/puppeteer-extra), a modular plugin framework for [`puppeteer`](https://github.com/puppeteer/puppeteer). :-)

🌟 **For the main documentation, please head over to the [`puppeteer-extra`](./packages/puppeteer-extra) package.**

In case you're interested in the available plugins, check out the [packages folder](./packages/).
We've also recently introduced support for Playwright, if you're interested in that head over to [`playwright-extra`](./packages/playwright-extra).

## Monorepo

Expand All @@ -28,6 +28,14 @@ This monorepo is powered by [Lerna](https://github.com/lerna/lerna) and yarn wor

#### Initial setup

- Make sure to have a recent Node.js version installed (hint: use `nvm`)
- Make sure `yarn` is recent (`>=1.2`), for better workspace support:

```bash
rm -rf ~/.yarn && npm install --global yarn && yarn --version
# Issues? Check your PATH and `which yarn`
```

```bash
# Install deps
yarn
Expand All @@ -40,6 +48,10 @@ yarn bootstrap
yarn build
```

#### Troubleshooting

> **Note regarding `fsevents`:** If you are working from a non-OSX environment you may need to run `npx json -I -f package.json -e 'this.resolutions={}'` prior to the initial `yarn` command to allow correct installation. This is a local fix and not meant to be commited afterwards.

#### Development flow

```bash
Expand All @@ -53,6 +65,9 @@ yarn lerna add fs-extra --scope=puppeteer-extra-plugin-user-data-dir
# https://github.com/lerna/lerna/issues/833
yarn lerna exec --concurrency 1 'yarn remove fs-extra; echo 0'

# Make sure firefox is installed and symlinked
yarn download-firefox

# Run test in all packages
yarn test

Expand Down
70 changes: 70 additions & 0 deletions helpers/scripts/download-firefox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const fs = require('fs')
const path = require('path')

try {
require('puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js')
} catch (err) {
console.log(
'Error importing BrowserFetcher, this means puppeteer is not installed or an old version is used. Skipping.'
)
process.exit(0)
}

const {
BrowserFetcher
} = require('puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js')

const {
downloadBrowser
} = require('puppeteer/lib/cjs/puppeteer/node/install.js')

const fetchUrl = url =>
new Promise((resolve, reject) => {
require('https')
.get(url, resp => {
let data = ''
resp.on('data', chunk => {
data += chunk
})
resp.on('end', () => {
resolve(data)
})
})
.on('error', err => {
reject(err)
})
})

async function main() {
const browserFetcher = new BrowserFetcher(
path.join(process.cwd(), './node_modules/puppeteer'),
{
product: 'firefox'
}
)
const firefoxVersion = JSON.parse(
await fetchUrl(
'https://product-details.mozilla.org/1.0/firefox_versions.json'
)
).FIREFOX_NIGHTLY

const sourceDir = browserFetcher.revisionInfo(firefoxVersion).folderPath
const targetDir = browserFetcher.revisionInfo('latest').folderPath

process.env.PUPPETEER_PRODUCT = 'firefox'
await downloadBrowser()

try {
await fs.promises.unlink(targetDir)
} catch (err) {}

try {
await fs.promises.symlink(sourceDir, targetDir)
} catch (err) {
console.log(err)
}

console.log(`${sourceDir} => ${targetDir}`)
}

main()
22 changes: 22 additions & 0 deletions helpers/test/wrap/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@extra-test/wrap",
"private": true,
"version": "1.0.0",
"typings": "dist/index.d.ts",
"main": "dist/index.js",
"files": [
"dist"
],
"license": "MIT",
"scripts": {
"build": "tsc --build",
"watch": "npx wait-run --pattern 'src/**' yarn watch:build",
"watch:build": "yarn build; yarn watch"
},
"devDependencies": {
"@types/node": "^14.6.2",
"automation-extra": "*",
"ts-node": "^9.0.0",
"typescript": "4.1.2"
}
}
3 changes: 3 additions & 0 deletions helpers/test/wrap/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# testing-tools

Internal package to make multi driver/browser testing more convenient.
Loading