chore: npm packages (#525)
## playwright-chromium - installs chromium - exposes chromium api from playwright-core ## playwright-firefox - installs firefox - exposes firefox api from playwright-core ## playwright-webkit - installs webkit - exposes webkit api from playwright-core ## playwright-core - downloads no browsers - contains all of the js code - designed for internal use ## playwright - downloads all browsers - exposes the entire api from playwright-core ## github - downloads all browsers, generates protocol definitions, builds typescript - exposes "playwright-core" api
This commit is contained in:
Родитель
575c72f93a
Коммит
fa1d286d56
|
@ -10,11 +10,11 @@ lib/injected/
|
|||
!lib/**/*.d.ts
|
||||
!index.d.ts
|
||||
|
||||
# Install
|
||||
!install.js
|
||||
# used for npm install scripts
|
||||
!download-browser.js
|
||||
|
||||
# root for "playwright" package
|
||||
# root for "playwright-core" package
|
||||
!index.js
|
||||
|
||||
# root for "playwright/web"
|
||||
# root for "playwright-core/web"
|
||||
!web.js
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/**
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
* Modifications copyright (c) Microsoft Corporation.
|
||||
* 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
|
||||
* 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,
|
||||
|
@ -15,47 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// This file is only run when someone clones the github repo for development
|
||||
|
||||
try {
|
||||
require('child_process').execSync('npm run build', {
|
||||
stdio: 'ignore'
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
(async function() {
|
||||
let protocolGenerator;
|
||||
try {
|
||||
protocolGenerator = require('./utils/protocol-types-generator');
|
||||
} catch (e) {
|
||||
// Release mode
|
||||
}
|
||||
try {
|
||||
const chromeRevision = await downloadBrowser('chromium', require('./index').chromium);
|
||||
if (protocolGenerator)
|
||||
await protocolGenerator.generateChromiunProtocol(chromeRevision);
|
||||
} catch (e) {
|
||||
console.warn(e.message);
|
||||
}
|
||||
|
||||
try {
|
||||
const firefoxRevision = await downloadBrowser('firefox', require('./index').firefox);
|
||||
if (protocolGenerator)
|
||||
await protocolGenerator.generateFirefoxProtocol(firefoxRevision);
|
||||
} catch (e) {
|
||||
console.warn(e.message);
|
||||
}
|
||||
try {
|
||||
const webkitRevision = await downloadBrowser('webkit', require('./index').webkit);
|
||||
if (protocolGenerator)
|
||||
await protocolGenerator.generateWebKitProtocol(webkitRevision);
|
||||
} catch (e) {
|
||||
console.warn(e.message);
|
||||
}
|
||||
})();
|
||||
|
||||
async function downloadBrowser(browser, playwright) {
|
||||
async function downloadBrowser(browser) {
|
||||
const playwright = require('.')[browser];
|
||||
let progressBar = null;
|
||||
let lastDownloadedBytes = 0;
|
||||
function onProgress(downloadedBytes, totalBytes) {
|
||||
|
@ -80,13 +40,10 @@ async function downloadBrowser(browser, playwright) {
|
|||
return revisionInfo;
|
||||
await fetcher.download(revisionInfo.revision, onProgress);
|
||||
logPolitely(`${browser} downloaded to ${revisionInfo.folderPath}`);
|
||||
const localRevisions = await fetcher.localRevisions();
|
||||
// Remove previous revisions.
|
||||
const cleanupOldVersions = localRevisions.filter(revision => revision !== revisionInfo.revision).map(revision => fetcher.remove(revision));
|
||||
await Promise.all([...cleanupOldVersions]);
|
||||
return revisionInfo;
|
||||
}
|
||||
|
||||
|
||||
function toMegabytes(bytes) {
|
||||
const mb = bytes / 1024 / 1024;
|
||||
return `${Math.round(mb * 10) / 10} Mb`;
|
||||
|
@ -100,3 +57,4 @@ function logPolitely(toBeLogged) {
|
|||
console.log(toBeLogged);
|
||||
}
|
||||
|
||||
module.exports = {downloadBrowser};
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "playwright",
|
||||
"name": "playwright-core",
|
||||
"version": "0.9.17-post",
|
||||
"description": "A high-level API to automate web browsers",
|
||||
"repository": "github:Microsoft/playwright",
|
||||
|
@ -19,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 && node utils/testrunner/test/test.js",
|
||||
"install": "node install.js",
|
||||
"prepare": "node prepare.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",
|
||||
|
@ -28,7 +28,8 @@
|
|||
"tsc": "tsc -p .",
|
||||
"build": "node utils/runWebpack.js --mode='development' && tsc -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",
|
||||
"version": "node utils/sync_package_versions.js"
|
||||
},
|
||||
"author": {
|
||||
"name": "Microsoft Corporation"
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
# playwright-chromium
|
||||
This packagage contains the [Chromium](https://www.chromium.org/) flavor of [Playwright](http://github.com/microsoft/playwright).
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
module.exports = require('playwright-core').chromium;
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* 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 {downloadBrowser} = require('playwright-core/download-browser');
|
||||
downloadBrowser('chromium');
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "playwright-chromium",
|
||||
"version": "0.9.17-post",
|
||||
"description": "A high-level API to automate Chromium",
|
||||
"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"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
# playwright-firefox
|
||||
This packagage contains the [Firefox](https://www.mozilla.org/firefox/) flavor of [Playwright](http://github.com/microsoft/playwright).
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
module.exports = require('playwright-core').firefox;
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* 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 {downloadBrowser} = require('playwright-core/download-browser');
|
||||
downloadBrowser('firefox');
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "playwright-firefox",
|
||||
"version": "0.9.17-post",
|
||||
"description": "A high-level API to automate Firefox",
|
||||
"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"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
# playwright-webkit
|
||||
This packagage contains the [WebKit](https://www.webkit.org/) flavor of [Playwright](http://github.com/microsoft/playwright).
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
module.exports = require('playwright-core').webkit;
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* 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 {downloadBrowser} = require('playwright-core/download-browser');
|
||||
downloadBrowser('webkit');
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "playwright-webkit",
|
||||
"version": "0.9.17-post",
|
||||
"description": "A high-level API to automate WebKit",
|
||||
"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"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
# playwright
|
||||
This packagage contains the [Chromium](https://www.chromium.org/), [Firefox](https://www.mozilla.org/firefox/) and [WebKit](https://www.webkit.org/) flavors of [Playwright](http://github.com/microsoft/playwright).
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
module.exports = require('playwright-core');
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* 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 {downloadBrowser} = require('playwright-core/download-browser');
|
||||
(async function() {
|
||||
await downloadBrowser('chromium');
|
||||
await downloadBrowser('firefox');
|
||||
await downloadBrowser('webkit');
|
||||
})();
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"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",
|
||||
"dependencies": {
|
||||
"playwright-core": "=0.9.13-post"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
* Modifications 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.
|
||||
*/
|
||||
|
||||
// This file is only run when someone installs via the github repo
|
||||
|
||||
try {
|
||||
console.log('Building playwright...');
|
||||
require('child_process').execSync('npm run build', {
|
||||
stdio: 'ignore'
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
const {downloadBrowser} = require('./download-browser');
|
||||
|
||||
(async function() {
|
||||
const protocolGenerator = require('./utils/protocol-types-generator');
|
||||
try {
|
||||
const chromeRevision = await downloadAndCleanup('chromium');
|
||||
await protocolGenerator.generateChromiunProtocol(chromeRevision);
|
||||
} catch (e) {
|
||||
console.warn(e.message);
|
||||
}
|
||||
|
||||
try {
|
||||
const firefoxRevision = await downloadAndCleanup('firefox');
|
||||
await protocolGenerator.generateFirefoxProtocol(firefoxRevision);
|
||||
} catch (e) {
|
||||
console.warn(e.message);
|
||||
}
|
||||
|
||||
try {
|
||||
const webkitRevision = await downloadAndCleanup('webkit');
|
||||
await protocolGenerator.generateWebKitProtocol(webkitRevision);
|
||||
} catch (e) {
|
||||
console.warn(e.message);
|
||||
}
|
||||
})();
|
||||
|
||||
async function downloadAndCleanup(browser) {
|
||||
const revisionInfo = await downloadBrowser(browser);
|
||||
|
||||
// Remove previous revisions.
|
||||
const playwright = require('.')[browser];
|
||||
const fetcher = playwright._createBrowserFetcher();
|
||||
const localRevisions = await fetcher.localRevisions();
|
||||
const cleanupOldVersions = localRevisions.filter(revision => revision !== revisionInfo.revision).map(revision => fetcher.remove(revision));
|
||||
await Promise.all([...cleanupOldVersions]);
|
||||
|
||||
return revisionInfo;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* 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');
|
||||
|
||||
for (const packageName of ['playwright-chromium', 'playwright-firefox', 'playwright-webkit', 'playwright']) {
|
||||
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');
|
||||
}
|
Загрузка…
Ссылка в новой задаче