chore: npm packages

This commit is contained in:
Joel 2020-01-17 20:25:31 +00:00 committed by Joel Einbinder
parent 894e91bb68
commit 6b73dbd305
18 changed files with 234 additions and 5 deletions

View file

@ -10,9 +10,6 @@ lib/injected/
!lib/**/*.d.ts !lib/**/*.d.ts
!index.d.ts !index.d.ts
# Install
!install.js
# root for "playwright" package # root for "playwright" package
!index.js !index.js

View file

@ -1,5 +1,5 @@
{ {
"name": "playwright", "name": "playwright-core",
"version": "0.9.17-post", "version": "0.9.17-post",
"description": "A high-level API to automate web browsers", "description": "A high-level API to automate web browsers",
"repository": "github:Microsoft/playwright", "repository": "github:Microsoft/playwright",
@ -28,7 +28,8 @@
"tsc": "tsc -p .", "tsc": "tsc -p .",
"build": "node utils/runWebpack.js --mode='development' && tsc -p .", "build": "node utils/runWebpack.js --mode='development' && tsc -p .",
"watch": "node utils/runWebpack.js --mode='development' --watch --silent | tsc -w -p .", "watch": "node utils/runWebpack.js --mode='development' --watch --silent | tsc -w -p .",
"apply-next-version": "node utils/apply_next_version.js" "apply-next-version": "node utils/apply_next_version.js",
"sync-versions": "node utils/sync_package_versions.js"
}, },
"author": { "author": {
"name": "Microsoft Corporation" "name": "Microsoft Corporation"

View file

@ -0,0 +1,2 @@
# playwright-chromium
This packagage contains the [Chromium](https://www.chromium.org/) flavor of [Playwright](http://github.com/microsoft/playwright).

View file

@ -0,0 +1 @@
module.exports = require('playwright-core').chromium;

View file

@ -0,0 +1,39 @@
downloadBrowser('chromium', require('./index').chromium);
async function downloadBrowser(browser, playwright) {
let progressBar = null;
let lastDownloadedBytes = 0;
function onProgress(downloadedBytes, totalBytes) {
if (!progressBar) {
const ProgressBar = require('progress');
progressBar = new ProgressBar(`Downloading ${browser} ${playwright._revision} - ${toMegabytes(totalBytes)} [:bar] :percent :etas `, {
complete: '=',
incomplete: ' ',
width: 20,
total: totalBytes,
});
}
const delta = downloadedBytes - lastDownloadedBytes;
lastDownloadedBytes = downloadedBytes;
progressBar.tick(delta);
}
const fetcher = playwright._createBrowserFetcher();
const revisionInfo = fetcher.revisionInfo();
await fetcher.download(revisionInfo.revision, onProgress);
logPolitely(`${browser} downloaded to ${revisionInfo.folderPath}`);
}
function toMegabytes(bytes) {
const mb = bytes / 1024 / 1024;
return `${Math.round(mb * 10) / 10} Mb`;
}
function logPolitely(toBeLogged) {
const logLevel = process.env.npm_config_loglevel;
const logLevelDisplay = ['silent', 'error', 'warn'].indexOf(logLevel) > -1;
if (!logLevelDisplay)
console.log(toBeLogged);
}

View file

@ -0,0 +1,17 @@
{
"name": "playwright-chromium",
"version": "0.9.17-post",
"description": "A high-level API to automate web browsers",
"repository": "github:Microsoft/playwright",
"main": "index.js",
"scripts": {
"install": "node install.js"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "=0.9.17-post"
}
}

View file

@ -0,0 +1,2 @@
# playwright-firefox
This packagage contains the [Firefox](https://www.mozilla.org/firefox/) flavor of [Playwright](http://github.com/microsoft/playwright).

View file

@ -0,0 +1 @@
module.exports = require('playwright-core').firefox;

View file

@ -0,0 +1,39 @@
downloadBrowser('firefox', require('./index').firefox);
async function downloadBrowser(browser, playwright) {
let progressBar = null;
let lastDownloadedBytes = 0;
function onProgress(downloadedBytes, totalBytes) {
if (!progressBar) {
const ProgressBar = require('progress');
progressBar = new ProgressBar(`Downloading ${browser} ${playwright._revision} - ${toMegabytes(totalBytes)} [:bar] :percent :etas `, {
complete: '=',
incomplete: ' ',
width: 20,
total: totalBytes,
});
}
const delta = downloadedBytes - lastDownloadedBytes;
lastDownloadedBytes = downloadedBytes;
progressBar.tick(delta);
}
const fetcher = playwright._createBrowserFetcher();
const revisionInfo = fetcher.revisionInfo();
await fetcher.download(revisionInfo.revision, onProgress);
logPolitely(`${browser} downloaded to ${revisionInfo.folderPath}`);
}
function toMegabytes(bytes) {
const mb = bytes / 1024 / 1024;
return `${Math.round(mb * 10) / 10} Mb`;
}
function logPolitely(toBeLogged) {
const logLevel = process.env.npm_config_loglevel;
const logLevelDisplay = ['silent', 'error', 'warn'].indexOf(logLevel) > -1;
if (!logLevelDisplay)
console.log(toBeLogged);
}

View file

@ -0,0 +1,17 @@
{
"name": "playwright-firefox",
"version": "0.9.17-post",
"description": "A high-level API to automate web browsers",
"repository": "github:Microsoft/playwright",
"main": "index.js",
"scripts": {
"install": "node install.js"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "=0.9.17-post"
}
}

View file

@ -0,0 +1,2 @@
# playwright-webkit
This packagage contains the [WebKit](https://www.webkit.org/) flavor of [Playwright](http://github.com/microsoft/playwright).

View file

@ -0,0 +1 @@
module.exports = require('playwright-core').webkit;

View file

@ -0,0 +1,39 @@
downloadBrowser('webkit', require('./index').webkit);
async function downloadBrowser(browser, playwright) {
let progressBar = null;
let lastDownloadedBytes = 0;
function onProgress(downloadedBytes, totalBytes) {
if (!progressBar) {
const ProgressBar = require('progress');
progressBar = new ProgressBar(`Downloading ${browser} ${playwright._revision} - ${toMegabytes(totalBytes)} [:bar] :percent :etas `, {
complete: '=',
incomplete: ' ',
width: 20,
total: totalBytes,
});
}
const delta = downloadedBytes - lastDownloadedBytes;
lastDownloadedBytes = downloadedBytes;
progressBar.tick(delta);
}
const fetcher = playwright._createBrowserFetcher();
const revisionInfo = fetcher.revisionInfo();
await fetcher.download(revisionInfo.revision, onProgress);
logPolitely(`${browser} downloaded to ${revisionInfo.folderPath}`);
}
function toMegabytes(bytes) {
const mb = bytes / 1024 / 1024;
return `${Math.round(mb * 10) / 10} Mb`;
}
function logPolitely(toBeLogged) {
const logLevel = process.env.npm_config_loglevel;
const logLevelDisplay = ['silent', 'error', 'warn'].indexOf(logLevel) > -1;
if (!logLevelDisplay)
console.log(toBeLogged);
}

View file

@ -0,0 +1,17 @@
{
"name": "playwright-webkit",
"version": "0.9.17-post",
"description": "A high-level API to automate web browsers",
"repository": "github:Microsoft/playwright",
"main": "index.js",
"scripts": {
"install": "node install.js"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "=0.9.17-post"
}
}

View file

@ -0,0 +1,2 @@
# playwright
This is a placeholder package for [Playwright](http://github.com/microsoft/playwright). Install one of `playwright-chromium`, `playwright-webkit`, or `playwright-firefox` to use playwright.

View file

@ -0,0 +1,2 @@
console.error('This package, "playwright", is a placeholder. Please install "playwright-chromium", "playwright-firefox", or "playwright-webkit" to use playwright.');
process.exit(1);

View file

@ -0,0 +1,14 @@
{
"name": "playwright",
"version": "0.9.17-post",
"description": "A high-level API to automate web browsers",
"repository": "github:Microsoft/playwright",
"main": "index.js",
"scripts": {
"install": "node install.js"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0"
}

View file

@ -0,0 +1,36 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const fs = require('fs');
const path = require('path');
const {version} = require('../package.json');
updatePackage('playwright', packageJSON => {
packageJSON.version = version;
});
for (const packageName of ['playwright-chromium', 'playwright-firefox', 'playwright-webkit']) {
updatePackage(packageName, packageJSON => {
packageJSON.version = version;
packageJSON.dependencies['playwright-core'] = `=${version}`;
});
}
function updatePackage(packageName, transform) {
const packageJSONPath = path.join(__dirname, '..', 'packages', packageName, 'package.json');
console.log(`Updating ${packageJSONPath} to ${version}.`);
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath));
transform(packageJSON);
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, undefined, 2) + '\n');
}