Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: prepare to npm publish (#148)

Dmitry Gozman0a9377e0a9c8
diff --git a/.gitignore b/.gitignore
index 311c1c0bb1..61a0cef2d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,4 @@ yarn.lock
/utils/browser/playwright-web.js
/index.d.ts
lib/
+playwright-*.tgz
diff --git a/.npmignore b/.npmignore
index f333d1d5f8..ae04ec7472 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,48 +1,20 @@
-.appveyor.yml
-.gitattributes
+# this ignores everything by default, except for package.json and LICENSE and README.md
+# see https://docs.npmjs.com/misc/developers
+**/*
-# no longer generated, but old checkouts might still have it
-node6
+# include sources from lib except for injected, but not map files
+!lib/**/*.js
+# Injected files are included via lib/generated, see src/injected/README.md
+lib/injected/
-# exclude all tests
-test
-utils/node6-transform
+# root for "playwright" package
+!index.js
-# exclude source files
-src
+# specific browsers
+!chromium.js
+!firefox.js
+!webkit.js
-# repeats from .gitignore
-node_modules
-.local-chromium
-.local-browser
-.local-webkit
-.dev_profile*
-.DS_Store
-*.swp
-*.pyc
-.vscode
-package-lock.json
-/node6/test
-/node6/utils
-/test
-/utils
-/docs
-yarn.lock
-
-# other
-/.ci
-/examples
-.appveyour.yml
-.cirrus.yml
-.editorconfig
-.eslintignore
-.eslintrc.js
-.travis.yml
-README.md
-tsconfig.json
-
-# exclude types, see https://github.com/GoogleChrome/puppeteer/issues/3878
-/index.d.ts
-
-# install.js only does stuff for development
-/install.js
+# Dgozman says to remove these
+!DeviceDescriptors.js
+!Errors.js
diff --git a/examples/download-and-verify.js b/examples/download-and-verify.js
new file mode 100644
index 0000000000..beab8f8f8a
--- /dev/null
+++ b/examples/download-and-verify.js
@@ -0,0 +1,17 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT license.
+
+(async () => {
+ const browserName = process.argv[2];
+ const playwright = require('playwright')(browserName);
+
+ console.log('downloading ' + browserName + '...');
+ const revisionInfo = await playwright.downloadBrowser();
+ console.log('downloaded to ' + revisionInfo.folderPath);
+
+ console.log('checking user agent...');
+ const browser = await playwright.launch();
+ const page = await browser.newPage();
+ console.log(await page.evaluate('navigator.userAgent'));
+ await browser.close();
+})()
diff --git a/index.js b/index.js
new file mode 100644
index 0000000000..967fac7f93
--- /dev/null
+++ b/index.js
@@ -0,0 +1,12 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT license.
+
+module.exports = browser => {
+ if (browser === 'chromium')
+ return require('./chromium');
+ if (browser === 'firefox')
+ return require('./firefox');
+ if (browser === 'webkit')
+ return require('./webkit');
+ throw new Error(`Unsupported browser "${browser}"`);
+};
diff --git a/package.json b/package.json
index 634aed013f..a1ae90e790 100644
--- a/package.json
+++ b/package.json
@@ -1,11 +1,12 @@
{
"name": "playwright",
"version": "0.9.0-post",
- "description": "A high-level API to control headless Chrome over the DevTools Protocol",
+ "description": "A high-level API to control web browsers",
"repository": "github:Microsoft/playwright",
"engines": {
"node": ">=10.17.0"
},
+ "main": "index.js",
"playwright": {
"chromium_revision": "719491",
"firefox_revision": "1004",
@@ -18,7 +19,7 @@
"debug-unit": "node --inspect-brk test/test.js",
"test-doclint": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js",
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-types && node utils/testrunner/test/test.js",
- "install": "node install.js",
+ "prepare": "node install.js",
"lint": "([ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src) && npm run tsc && npm run doc",
"doc": "node utils/doclint/cli.js",
"coverage": "cross-env COVERAGE=true npm run unit",
@@ -30,8 +31,10 @@
"test-types": "node utils/doclint/generate_types && npx -p [email protected] tsc -p utils/doclint/generate_types/test/",
"unit-bundle": "node utils/browser/test.js"
},
- "author": "The Chromium Authors",
- "license": "Apache-2.0",
+ "author": {
+ "name": "Microsoft Corporation"
+ },
+ "license": "MIT",
"dependencies": {
"debug": "^4.1.0",
"extract-zip": "^1.6.6",