Skip to content

Commit

Permalink
chore: prepare to npm publish (microsoft#148)
Browse files Browse the repository at this point in the history
- setup .npmignore;
- index.js selecting a browser;
- minor package.json tweaks;
- example script which works against npm pack'ed module.
  • Loading branch information
dgozman authored and JoelEinbinder committed Dec 5, 2019
1 parent 4478c65 commit 0a9377e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ yarn.lock
/utils/browser/playwright-web.js
/index.d.ts
lib/
playwright-*.tgz
60 changes: 16 additions & 44 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions examples/download-and-verify.js
Original file line number Diff line number Diff line change
@@ -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();
})()
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -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}"`);
};
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 0a9377e

Please sign in to comment.