Skip to content

Commit c1ee29f

Browse files
authored
Merge pull request #479 from angrykoala/dev
Release 2.14.0
2 parents 5caafff + 0c8141c commit c1ee29f

File tree

16 files changed

+246
-139
lines changed

16 files changed

+246
-139
lines changed

.eslintignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
dist/
1+
dist/
2+
.eslint.js
3+
node_modules

.eslintrc.json renamed to .eslintrc-js.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
module.exports = {
22
"env": {
33
"mocha": true,
44
"node": true,

.eslintrc-ts.js

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/*
2+
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
3+
https://github.com/typescript-eslint/tslint-to-eslint-config
4+
5+
It represents the closest reasonable ESLint configuration to this
6+
project's original TSLint configuration.
7+
8+
We recommend eventually switching this configuration to extend from
9+
the recommended rulesets in typescript-eslint.
10+
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
11+
12+
Happy linting! 💖
13+
*/
14+
module.exports = {
15+
"env": {
16+
"browser": true,
17+
"es6": true,
18+
"node": true
19+
},
20+
"extends": [
21+
"plugin:@typescript-eslint/recommended",
22+
"plugin:@typescript-eslint/recommended-requiring-type-checking"
23+
],
24+
"parser": "@typescript-eslint/parser",
25+
"parserOptions": {
26+
"project": "tsconfig.json",
27+
"sourceType": "module"
28+
},
29+
"plugins": [
30+
"eslint-plugin-prefer-arrow",
31+
"@typescript-eslint"
32+
],
33+
"rules": {
34+
"@typescript-eslint/adjacent-overload-signatures": "error",
35+
"@typescript-eslint/array-type": "off",
36+
"@typescript-eslint/ban-types": [
37+
"error",
38+
{
39+
"types": {
40+
"Boolean": {
41+
"message": "Avoid using the `Boolean` type. Did you mean `boolean`?"
42+
},
43+
"Number": {
44+
"message": "Avoid using the `Number` type. Did you mean `number`?"
45+
},
46+
"String": {
47+
"message": "Avoid using the `String` type. Did you mean `string`?"
48+
},
49+
"Symbol": {
50+
"message": "Avoid using the `Symbol` type. Did you mean `symbol`?"
51+
}
52+
}
53+
}
54+
],
55+
"@typescript-eslint/consistent-type-assertions": "error",
56+
"@typescript-eslint/dot-notation": "error",
57+
"@typescript-eslint/explicit-module-boundary-types": "off",
58+
"@typescript-eslint/member-ordering": "off",
59+
"@typescript-eslint/naming-convention": "off",
60+
"@typescript-eslint/no-empty-function": "error",
61+
"@typescript-eslint/no-empty-interface": "off",
62+
"@typescript-eslint/no-explicit-any": "off",
63+
"@typescript-eslint/no-floating-promises": "off",
64+
"@typescript-eslint/no-inferrable-types": "off",
65+
"@typescript-eslint/no-misused-new": "error",
66+
"@typescript-eslint/no-misused-promises": "off",
67+
"@typescript-eslint/no-namespace": "off",
68+
"@typescript-eslint/no-parameter-properties": "off",
69+
"@typescript-eslint/no-unnecessary-type-assertion": "off",
70+
"@typescript-eslint/no-unsafe-assignment": "off",
71+
"@typescript-eslint/no-unsafe-call": "off",
72+
"@typescript-eslint/no-unsafe-member-access": "off",
73+
"@typescript-eslint/no-unsafe-return": "off",
74+
"@typescript-eslint/no-unused-expressions": "error",
75+
"@typescript-eslint/no-unused-vars": "off",
76+
"@typescript-eslint/no-use-before-define": "off",
77+
"@typescript-eslint/no-var-requires": "error",
78+
"@typescript-eslint/prefer-for-of": "off",
79+
"@typescript-eslint/prefer-function-type": "error",
80+
"@typescript-eslint/prefer-namespace-keyword": "error",
81+
"@typescript-eslint/prefer-regexp-exec": "off",
82+
"@typescript-eslint/quotes": "off",
83+
"@typescript-eslint/require-await": "off",
84+
"@typescript-eslint/restrict-plus-operands": "off",
85+
"@typescript-eslint/restrict-template-expressions": "off",
86+
"@typescript-eslint/triple-slash-reference": [
87+
"error",
88+
{
89+
"path": "always",
90+
"types": "prefer-import",
91+
"lib": "always"
92+
}
93+
],
94+
"@typescript-eslint/unified-signatures": "error",
95+
"arrow-parens": [
96+
"off",
97+
"always"
98+
],
99+
"comma-dangle": "off",
100+
"complexity": "off",
101+
"constructor-super": "error",
102+
"curly": "off",
103+
"eqeqeq": [
104+
"error",
105+
"smart"
106+
],
107+
"guard-for-in": "error",
108+
"id-blacklist": [
109+
"error",
110+
"any",
111+
"Number",
112+
"number",
113+
"String",
114+
"string",
115+
"Boolean",
116+
"boolean",
117+
"Undefined",
118+
"undefined"
119+
],
120+
"id-match": "error",
121+
"import/order": "off",
122+
"max-classes-per-file": "off",
123+
"max-len": [
124+
"error",
125+
{
126+
"code": 200
127+
}
128+
],
129+
"new-parens": "error",
130+
"no-bitwise": "error",
131+
"no-caller": "error",
132+
"no-cond-assign": "error",
133+
"no-console": "off",
134+
"no-debugger": "error",
135+
"no-empty": "error",
136+
"no-eval": "error",
137+
"no-fallthrough": "off",
138+
"no-invalid-this": "off",
139+
"no-new-wrappers": "error",
140+
"no-shadow": "off",
141+
"no-throw-literal": "error",
142+
"no-trailing-spaces": "error",
143+
"no-undef-init": "error",
144+
"no-underscore-dangle": "off",
145+
"no-unsafe-finally": "error",
146+
"no-unused-labels": "error",
147+
"no-var": "error",
148+
"object-shorthand": "off",
149+
"one-var": [
150+
"error",
151+
"never"
152+
],
153+
"prefer-arrow/prefer-arrow-functions": "off",
154+
"prefer-const": "off",
155+
"prefer-rest-params": "off",
156+
"radix": "error",
157+
"spaced-comment": [
158+
"error",
159+
"always",
160+
{
161+
"markers": [
162+
"/"
163+
]
164+
}
165+
],
166+
"use-isnan": "error",
167+
"valid-typeof": "off",
168+
}
169+
};

.github/workflows/npm-publish.yml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99

1010
jobs:
1111
publish-npm:
12-
needs: build
1312
runs-on: ubuntu-latest
1413
steps:
1514
- uses: actions/checkout@v2
@@ -27,21 +26,20 @@ jobs:
2726
env:
2827
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
2928

30-
publish-gpr:
31-
needs: build
32-
runs-on: ubuntu-latest
33-
steps:
34-
- uses: actions/checkout@v2
35-
- uses: actions/setup-node@v1
36-
with:
37-
node-version: 12
38-
registry-url: https://npm.pkg.github.com/
39-
- run: npm install
40-
- name: publish
41-
run: |
42-
sudo apt-get update
43-
sudo apt-get install -y libgbm-dev
44-
npm run lint
45-
npm publish
46-
env:
47-
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
29+
# publish-gpr:
30+
# runs-on: ubuntu-latest
31+
# steps:
32+
# - uses: actions/checkout@v2
33+
# - uses: actions/setup-node@v1
34+
# with:
35+
# node-version: 12
36+
# registry-url: https://npm.pkg.github.com/
37+
# - run: npm install
38+
# - name: publish
39+
# run: |
40+
# sudo apt-get update
41+
# sudo apt-get install -y libgbm-dev
42+
# npm run lint
43+
# npm publish
44+
# env:
45+
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2.14.0 / 2020-10-25
2+
===================
3+
4+
* Update Dockerfile to recommended Puppeteer setup
5+
* Docs updated
6+
* Tslint deprecated in favor of eslint
7+
* Minor typings improvements and fixes
8+
* Typescript version locked until Promise types are fixed
9+
* Dependencies updated
10+
* Fix in publish git workflow
11+
112
2.13.2 / 2020-10-24
213
===================
314

Dockerfile

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,16 @@
1-
FROM node:12-slim
1+
FROM node:lts-slim
22

33
WORKDIR /app
44

5-
RUN apt-get update && apt-get install -y -q --no-install-recommends\
6-
libasound2 \
7-
libatk1.0-0 \
8-
libc6 \
9-
libcairo2 \
10-
libcups2 \
11-
libdbus-1-3 \
12-
libexpat1 \
13-
libfontconfig1 \
14-
libgcc1 \
15-
libgconf-2-4 \
16-
libgdk-pixbuf2.0-0 \
17-
libglib2.0-0 \
18-
libgtk-3-0 \
19-
libnspr4 \
20-
libpango-1.0-0 \
21-
libpangocairo-1.0-0 \
22-
libstdc++6 \
23-
libx11-6 \
24-
libx11-xcb1 \
25-
libxcb1 \
26-
libxcomposite1 \
27-
libxcursor1 \
28-
libxdamage1 \
29-
libxext6 \
30-
libxfixes3 \
31-
libxi6 \
32-
libxrandr2 \
33-
libxrender1 \
34-
libxss1 \
35-
libxtst6 \
36-
ca-certificates \
37-
fonts-liberation \
38-
libappindicator1 \
39-
libnss3 \
40-
lsb-release \
41-
xdg-utils \
42-
wget \
43-
&& apt-get clean \
5+
ENV NO_SANDBOX=true
6+
7+
RUN apt-get update \
8+
&& apt-get install -y wget gnupg \
9+
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
10+
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
11+
&& apt-get update \
12+
&& apt-get install -y `apt-cache depends google-chrome-stable | awk '/Depends:/{print$2}'` fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
13+
--no-install-recommends \
4414
&& rm -rf /var/lib/apt/lists/*
4515

46-
ENV NO_SANDBOX=true
4716
RUN npm install wendigo && npm cache clean --force

README.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ Will create and return a promise to a [Browser](#Browser) instance. It will auto
151151
* `userAgent`: If defined, the default user agent will be overridden.
152152
* `noSandbox`: Sets the option `--no-sandbox` when opening Puppeteer. This option will also be set if the env variable `NO_SANDBOX` is set (check [troubleshooting](#troubleshooting)).
153153
* `timezone`: Sets the browser's timezone (e.g. `UTC`, `Asia/Tokyo`).
154-
* `dismissAllDialogs`: This will automatically dismiss any native dialog (`alert`, `prompt`) when appearing.
155154
* `bypassCSP: true`: If set to false, puppeteer may fail if Content Security Policy is set in the page.
156155
* `proxyServer: null`: If defined, Chromium will run with the option `--proxy-server` set to the given address.
157156
* `defaultTimeout: 500`: Sets the default timeout for "wait" methods, except `browser.wait()`.
@@ -229,6 +228,7 @@ The following options can be passed:
229228
* `queryString`: Querystring to be appended to the url, can be a string or object. Avoid using this parameter if a query string is already present in the url.
230229
* `geolocation`: Options to override geoLocation. Same as using `setGeolocation`.
231230
* `headers`: Sets extra HTTP headers _before_ opening the page.Same as using `requests.setHeaders`.
231+
* `dismissAllDialogs`: This will automatically dismiss any native dialog (`alert`, `prompt`) when appearing.
232232

233233
If no protocol is defined (e.g. `https://`), `http://` will be used.
234234

@@ -2017,17 +2017,12 @@ _Example of travis.yml file_
20172017
20182018
### Running Tests With Gitlab CI
20192019
2020-
Using gitlab with the default node image requires installing a few dependencies with `apt-get` before installing wendigo. Same as in travis, sandbox mode should be disabled with the env variable `NO_SANDBOX`. It is recommended to add `retry: 2` to allow the CI to execute the tests multiple times, as browser-based setup may fail frequently on CI workers:
2020+
It is recommended to add `retry: 2` to allow the CI to execute the tests multiple times, as browser-based setup may fail frequently on CI workers due to hardware resources needs:
20212021

20222022
```yml
2023-
image: node:8.9.4
2024-
2025-
variables:
2026-
NO_SANDBOX: "true"
2023+
image: angrykoala/wendigo
20272024
20282025
before_script:
2029-
- apt-get update
2030-
- apt-get install -y -q gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
20312026
- npm install
20322027
20332028
test:
@@ -2074,17 +2069,14 @@ Wendigo con be running on docker just as any other application using Puppeteer,
20742069
```dockerfile
20752070
FROM angrykoala/wendigo
20762071
2077-
# Example directory to run you app
2078-
WORKDIR /app
2079-
20802072
COPY package*.json ./
20812073
# Installs your up (it must have Wendigo as a dependency)
2082-
RUN npm install
2074+
RUN npm ci
20832075
# Copies the rest of your app
20842076
COPY . /app
20852077
20862078
# Runs your tests
2087-
CMD ["npm", "run", "test"]
2079+
CMD ["npm", "test"]
20882080
20892081
```
20902082

injection_scripts/wendigo_utils.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,17 @@ export default function WendigoUtilsLoader(): void {
5050

5151
// Based on https://github.com/capaj/proxy-date
5252
(window as any).Date = new Proxy(_origDate, {
53-
construct(target: typeof Date, args: Array<any>): Date {
53+
construct(target: typeof Date, args: Parameters<typeof target>): Date {
5454
if (args.length === 0) {
5555
return new target(getCurrentTimestamp());
5656
}
57-
// @ts-ignore
5857
return new target(...args);
5958
},
60-
get(_target: typeof Date, prop): () => number {
59+
get(target: typeof Date, prop): () => number {
6160
if (prop === 'now') {
6261
return () => getCurrentTimestamp();
6362
}
64-
// @ts-ignore
65-
return Reflect.get(...arguments);
63+
return Reflect.get(target, prop);
6664
},
6765
apply(target: typeof Date): string {
6866
return new target(getCurrentTimestamp()).toString();

lib/browser/mixins/browser_wait.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export default abstract class BrowserWait extends BrowserNavigation {
197197

198198
// TODO: this need to be completely reworked to make a sensible approach to error handling
199199
private _overrideWaitError(error: Error, options: { timeoutMessage: string, timeout: number, selector?: string }): Error {
200-
if (error instanceof PuppeteerErrors.TimeoutError || error instanceof TimeoutError) {
200+
if (error instanceof (PuppeteerErrors.TimeoutError as any) || error instanceof TimeoutError) {
201201
return new TimeoutError("", options.timeoutMessage, options.timeout);
202202
}
203203
if (error instanceof Error && error.message.match(/DOMException\:/) || error instanceof QueryError) {

0 commit comments

Comments
 (0)