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 /utils/browser/playwright-web.js
/index.d.ts /index.d.ts
lib/ lib/
playwright-*.tgz

View file

@ -1,48 +1,20 @@
.appveyor.yml # this ignores everything by default, except for package.json and LICENSE and README.md
.gitattributes # see https://docs.npmjs.com/misc/developers
**/*
# no longer generated, but old checkouts might still have it # include sources from lib except for injected, but not map files
node6 !lib/**/*.js
# Injected files are included via lib/generated, see src/injected/README.md
lib/injected/
# exclude all tests # root for "playwright" package
test !index.js
utils/node6-transform
# exclude source files # specific browsers
src !chromium.js
!firefox.js
!webkit.js
# repeats from .gitignore # Dgozman says to remove these
node_modules !DeviceDescriptors.js
.local-chromium !Errors.js
.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

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", "name": "playwright",
"version": "0.9.0-post", "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", "repository": "github:Microsoft/playwright",
"engines": { "engines": {
"node": ">=10.17.0" "node": ">=10.17.0"
}, },
"main": "index.js",
"playwright": { "playwright": {
"chromium_revision": "719491", "chromium_revision": "719491",
"firefox_revision": "1004", "firefox_revision": "1004",
@ -18,7 +19,7 @@
"debug-unit": "node --inspect-brk test/test.js", "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-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", "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", "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", "doc": "node utils/doclint/cli.js",
"coverage": "cross-env COVERAGE=true npm run unit", "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/", "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" "unit-bundle": "node utils/browser/test.js"
}, },
"author": "The Chromium Authors", "author": {
"license": "Apache-2.0", "name": "Microsoft Corporation"
},
"license": "MIT",
"dependencies": { "dependencies": {
"debug": "^4.1.0", "debug": "^4.1.0",
"extract-zip": "^1.6.6", "extract-zip": "^1.6.6",