chore: prepare to npm publish (#148)

- setup .npmignore;
- index.js selecting a browser;
- minor package.json tweaks;
- example script which works against npm pack'ed module.
This commit is contained in:
Dmitry Gozman 2019-12-05 11:29:16 -08:00 committed by Joel Einbinder
parent 4478c653fd
commit 0a9377e0a9
5 changed files with 53 additions and 48 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ yarn.lock
/utils/browser/playwright-web.js
/index.d.ts
lib/
playwright-*.tgz

View File

@ -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

View File

@ -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
index.js Normal file
View File

@ -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}"`);
};

View File

@ -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 typescript@2.1 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",