Skip to content

Commit 0a3dbc0

Browse files
Merge pull request #1 from austinkelleher/initial-files
Initial files
2 parents 9b21f3b + b0d437a commit 0a3dbc0

19 files changed

+4433
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
coverage
3+
dist
4+
yarn-error.log

.huskyrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"hooks": {
3+
"pre-commit": "lint-staged"
4+
}
5+
}

.lintstagedrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"linters": {
3+
"*.ts": [
4+
"prettier --write",
5+
"git add"
6+
],
7+
"*.{md,js,json}": [
8+
"prettier --write",
9+
"git add"
10+
]
11+
},
12+
"ignore": []
13+
}

.npmignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/src/
2+
/test/
3+
/coverage/
4+
tsconfig*
5+
.editorconfig
6+
.travis.yml
7+
tslint.json
8+
jest.config.js
9+
.huskyrc
10+
.lintstagedrc
11+
.prettierignore
12+
.prettierrc
13+
yarn-error.log

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
coverage

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
singleQuote: true,
3+
trailingComma: "es5",
4+
proseWrap: "always"
5+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020 Austin Kelleher
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,44 @@
11
# playwright-aws-lambda
2+
3+
Support for PlayWright running on AWS Lambda and Google Cloud Functions
4+
5+
## Install
6+
7+
```shell
8+
npm install playwrite-core playwright-aws-lambda --save
9+
```
10+
11+
## Usage
12+
13+
This package works with the `nodejs8.10`, `nodejs10.x` and `nodejs12.x` AWS
14+
Lambda runtimes out of the box.
15+
16+
```javascript
17+
const playwright = require('playwright-aws-lambda');
18+
19+
exports.handler = async (event, context) => {
20+
let result = null;
21+
let browser = null;
22+
23+
try {
24+
const browser = await playwright.launchChromium();
25+
const context = await browser.defaultContext();
26+
27+
const page = await context.newPage();
28+
await page.goto(event.url || 'https://example.com');
29+
30+
console.log('Page title: ', await page.title());
31+
} catch (error) {
32+
throw err;
33+
} finally {
34+
if (browser !== null) {
35+
await browser.close();
36+
}
37+
}
38+
};
39+
```
40+
41+
## Thanks / Credits
42+
43+
This project is based on the work of
44+
[chrome-aws-lambda](https://github.com/alixaxel/chrome-aws-lambda).

jest.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { defaults } = require('jest-config');
2+
3+
module.exports = {
4+
transform: {
5+
'^.+\\.ts$': 'ts-jest',
6+
},
7+
testMatch: ['<rootDir>/src/**/*.test.{js,ts}'],
8+
collectCoverageFrom: ['src/**/*.ts'],
9+
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'],
10+
testEnvironment: 'node',
11+
clearMocks: true,
12+
collectCoverage: true,
13+
// coverageThreshold: {
14+
// global: {
15+
// statements: 100,
16+
// branches: 100,
17+
// functions: 100,
18+
// lines: 100,
19+
// },
20+
// },
21+
};

package.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "playwright-aws-lambda",
3+
"version": "0.3.2",
4+
"description": "Support for running Microsoft's Playwrite on AWS Lambda and Google Cloud functions",
5+
"main": "./dist/src/",
6+
"author": "Austin Kelleher, [email protected]",
7+
"license": "MIT",
8+
"publishConfig": {
9+
"access": "public"
10+
},
11+
"engines": {
12+
"node": ">= 8.0.0"
13+
},
14+
"scripts": {
15+
"compile-src-cjs": "tsc --declaration --declarationDir ./dist -p tsconfig-src-cjs.json && cp -R ./src/bin ./dist/src",
16+
"precompile-src": "rm -rf ./dist",
17+
"compile-src": "yarn compile-src-cjs",
18+
"lint": "tslint --format codeFrame --project tsconfig.json 'src/**/*.ts' 'test/**/*.ts'",
19+
"pretest": "yarn lint",
20+
"test": "jest",
21+
"build": "yarn compile-src",
22+
"format-code": "prettier --write '**/*.[jt]s'"
23+
},
24+
"dependencies": {
25+
"lambdafs": "^1.3.0"
26+
},
27+
"peerDependencies": {
28+
"playwright-core": "0.10.0"
29+
},
30+
"devDependencies": {
31+
"@types/debug": "^4.1.5",
32+
"@types/jest": "^24.0.18",
33+
"@types/node": "~10",
34+
"husky": "^3.0.5",
35+
"jest": "^24.9.0",
36+
"lint-staged": "8.2.1",
37+
"nodemon": "^1.19.4",
38+
"playwright-core": "^0.10.0",
39+
"prettier": "^1.18.2",
40+
"ts-jest": "^24.0.2",
41+
"tslint": "^5.20.1",
42+
"tslint-config-prettier": "^1.18.0",
43+
"typescript": "^3.6.3"
44+
}
45+
}

0 commit comments

Comments
 (0)