Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: drop dependency on playwright-core in all our packages (#2318)

Andrey Lushnikov505d94ab1ac1
diff --git a/.gitignore b/.gitignore
index 3d0d6a506d..e4a3f126fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,5 +16,4 @@ yarn.lock
/src/firefox/protocol.ts
/src/webkit/protocol.ts
lib/
-playwright-*.tgz
/types/*
diff --git a/.npmignore b/.npmignore
index dc91417a90..bdf2eb3503 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,3 +1,6 @@
+# NOTE: .npmignore is copied over to every subpackage in //packages when NPM packages
+# are built.
+#
# this ignores everything by default, except for package.json and LICENSE and README.md
# see https://docs.npmjs.com/misc/developers
**/*
@@ -10,8 +13,11 @@ lib/injected/
!types/*
!index.d.ts
-# root for "playwright-core" package
!index.js
+!install.js
+!README.md
+!LICENSE
+!NOTICE
# browser descriptor
!browsers.json
diff --git a/packages/playwright/browsers.json b/browsers.json
similarity index 100%
rename from packages/playwright/browsers.json
rename to browsers.json
diff --git a/index-for-dev.js b/index-for-dev.js
index 5dbc13a174..6409628365 100644
--- a/index-for-dev.js
+++ b/index-for-dev.js
@@ -18,7 +18,6 @@ const { Playwright } = require('./lib/server/playwright');
const { Electron } = require('./lib/server/electron');
const path = require('path');
-const playwrightRoot = path.join(__dirname, 'packages', 'playwright');
-const playwright = new Playwright(playwrightRoot, require(path.join(playwrightRoot, 'browsers.json'))['browsers']);
+const playwright = new Playwright(__dirname, require(path.join(__dirname, 'browsers.json'))['browsers']);
playwright.electron = new Electron();
module.exports = playwright;
diff --git a/install-from-github.js b/install-from-github.js
index 50213de973..d9ae8c6126 100644
--- a/install-from-github.js
+++ b/install-from-github.js
@@ -64,10 +64,9 @@ async function downloadAllBrowsersAndGenerateProtocolTypes() {
const { installBrowsersWithProgressBar } = require('./lib/install/installer');
const protocolGenerator = require('./utils/protocol-types-generator');
const browserPaths = require('./lib/install/browserPaths');
- const playwrightRoot = path.join(__dirname, 'packages', 'playwright');
- const browsersPath = browserPaths.browsersPath(playwrightRoot);
- const browsers = require(path.join(playwrightRoot, 'browsers.json'))['browsers'];
- await installBrowsersWithProgressBar(playwrightRoot);
+ const browsersPath = browserPaths.browsersPath(__dirname);
+ const browsers = require(path.join(__dirname, 'browsers.json'))['browsers'];
+ await installBrowsersWithProgressBar(__dirname);
for (const browser of browsers) {
const browserPath = browserPaths.browserDirectory(browsersPath, browser);
await protocolGenerator.generateProtocol(browser.name, browserPaths.executablePath(browserPath, browser)).catch(console.warn);
diff --git a/package-lock.json b/package-lock.json
index a468055873..9e7a790674 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "playwright-core",
+ "name": "playwright-internal",
"version": "1.0.0-post",
"lockfileVersion": 1,
"requires": true,
diff --git a/package.json b/package.json
index 1f94000d75..72ad2c014d 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,6 @@
{
- "name": "playwright-core",
+ "name": "playwright-internal",
+ "private": true,
"version": "1.0.0-post",
"description": "A high-level API to automate web browsers",
"repository": "github:Microsoft/playwright",
diff --git a/packages/README.md b/packages/README.md
new file mode 100644
index 0000000000..b059cb8eb1
--- /dev/null
+++ b/packages/README.md
@@ -0,0 +1,47 @@
+# Managing and Publishing Playwright Packages
+
+## Overview
+
+- Playwright ships multiple packages to NPM. All packges that are published to NPM are listed as folders under [`//packages/`](../packages).
+- Playwright's [root package.json](../package.json) is **never published to NPM**. It is only used for devmode, e.g. when running `npm install` with no arguments or installing from github.
+- Playwright dependencies for all packages are the same and are managed with the [`root package.json`](../package.json).
+- Playwright browser versions for all packages are the same and are managed with the [`browsers.json`](../browsers.json).
+
+> **NOTE** As of May 20, 2020, the only exception is the `playwright-electron` package that
+> doesn't follow the pack and is published manually. This is due to it's pre-1.0 status.
+
+
+## Building NPM package
+
+To build a package that will be shipped to NPM, use [`//packages/build_package.js`](./build_package.js) script.
+The script populates package folder with contents, and then uses `npm pack` to archive the folder.
+
+As of May 20, 2020, [`//packages/build_package.js`](./build_package.js) does the following:
+- copies certain files and folders from `playwright-internal` to the subpackage (e.g. `//lib`, `//types`, `//LICENSE` etc)
+- generates `package.json` and puts it in the subpackage
+- generates `browsers.json` and puts it in the subpackage
+- uses `npm pack` to pack the subpackage folder
+- removes all the files that were added during the process
+
+To build `playwright` package and save result as `./playwright.tgz` file:
+
+```sh
+$ ./packages/build_package.js playwright ./playwright.tgz
+```
+
+To debug what files are put into the folder, use `--no-cleanup` flag and inspect the package folder:
+
+```sh
+$ ./packages/build_package.js playwright ./playwright.tgz --no-cleanup
+$ ls ./packages/playwright # inspect the folder
+```
+
+
+## Testing packages
+
+To test packages, use [`//tests/installation-tests/installation-tests.sh`](../tests/installation-tests/installation-tests.sh).
+
+
+## Publishing packages
+
+ All package publishing happens **exclusively** over CI/CD using the [`//utils/publish_all_packages.sh`](../utils/publish_all_packages.sh) script.
diff --git a/packages/build_package.js b/packages/build_package.js
new file mode 100755
index 0000000000..6f5022e716
--- /dev/null
+++ b/packages/build_package.js
@@ -0,0 +1,174 @@
+#!/usr/bin/env node
+/**
+ * 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 rmSync = require('rimraf').sync;
+const ncp = require('ncp');
+const {spawnSync} = require('child_process');
+const util = require('util');
+
+const writeFileAsync = util.promisify(fs.writeFile.bind(fs));
+const cpAsync = util.promisify(ncp);
+
+const SCRIPT_NAME = path.basename(__filename);
+const ROOT_PATH = path.join(__dirname, '..');
+
+const PACKAGE_FILES = ['lib', 'types', 'NOTICE', 'LICENSE', '.npmignore'];
+
+const PACKAGES = {
+ 'playwright': {
+ description: 'A high-level API to automate web browsers',
+ whitelistedBrowsers: ['chromium', 'firefox', 'webkit'],
+ // We copy README.md additionally for Playwright so that it looks nice on NPM.
+ files: [...PACKAGE_FILES, 'README.md'],
+ },
+ 'playwright-core': {
+ description: 'A high-level API to automate web browsers',
+ whitelistedBrowsers: [],
+ files: PACKAGE_FILES,
+ },
+ 'playwright-webkit': {
+ description: 'A high-level API to automate WebKit',
+ whitelistedBrowsers: ['webkit'],
+ files: PACKAGE_FILES,
+ },
+ 'playwright-firefox': {
+ description: 'A high-level API to automate Firefox',
+ whitelistedBrowsers: ['firefox'],
+ files: PACKAGE_FILES,
+ },
+ 'playwright-chromium': {
+ description: 'A high-level API to automate Chromium',
+ whitelistedBrowsers: ['chromium'],
+ files: PACKAGE_FILES,
+ },
+};
+
+const cleanupPaths = [];
+
+// 1. Parse CLI arguments
+const args = process.argv.slice(2);
+if (args.some(arg => arg === '--help')) {
+ console.log(usage());
+ process.exit(1);
+} else if (args.length < 1) {
+ console.log(`Please specify package name, e.g. 'playwright' or 'playwright-chromium'.`);
+ console.log(`Try running ${SCRIPT_NAME} --help`);
+ process.exit(1);
+} else if (args.length < 2) {
+ console.log(`Please specify output path`);
+ console.log(`Try running ${SCRIPT_NAME} --help`);
+ process.exit(1);
+}
+
+// 2. Setup cleanup if needed
+if (!args.some(arg => arg === '--no-cleanup')) {
+ process.on('exit', () => {
+ cleanupPaths.forEach(cleanupPath => rmSync(cleanupPath, {}));
+ });
+ process.on('SIGINT', () => process.exit(2));
+ process.on('SIGHUP', () => process.exit(3));
+ process.on('SIGTERM', () => process.exit(4));
+ process.on('uncaughtException', error => {
+ console.error(error);
+ process.exit(5);
+ });
+ process.on('unhandledRejection', error => {
+ console.error(error);
+ process.exit(6);
+ });
+}
+
+const packageName = args[0];
+const outputPath = path.resolve(args[1]);
+const packagePath = path.join(__dirname, packageName);
+const package = PACKAGES[packageName];
+if (!package) {
+ console.log(`ERROR: unknown package ${packageName}`);
+ process.exit(1);
+}
+
+(async () => {
+ // 3. Copy package files.
+ for (const file of package.files)
+ await copyToPackage(file);
+
+ // 4. Generate package.json
+ const packageJSON = require(path.join(ROOT_PATH, 'package.json'));
+ await writeToPackage('package.json', JSON.stringify({
+ name: packageName,
+ version: packageJSON.version,
+ description: package.description,
+ repository: packageJSON.repository,
+ engines: packageJSON.engines,
+ homepage: packageJSON.homepage,
+ main: 'index.js',
+ scripts: {
+ install: 'node install.js',
+ },
+ author: packageJSON.author,
+ license: packageJSON.license,
+ dependencies: packageJSON.dependencies
+ }, null, 2));
+
+ // 5. Generate browsers.json
+ const browsersJSON = require(path.join(ROOT_PATH, 'browsers.json'));
+ browsersJSON.browsers = browsersJSON.browsers.filter(browser => package.whitelistedBrowsers.includes(browser.name));
+ await writeToPackage('browsers.json', JSON.stringify(browsersJSON, null, 2));
+
+ // 6. Run npm pack
+ const {stdout, stderr, status} = spawnSync('npm', ['pack'], {cwd: packagePath, encoding: 'utf8'});
+ if (status !== 0) {
+ console.log(`ERROR: "npm pack" failed`);
+ console.log(stderr);
+ process.exit(1);
+ }
+ const tgzName = stdout.trim();
+
+ // 7. Move result to the outputPath
+ fs.renameSync(path.join(packagePath, tgzName), outputPath);
+ console.log(outputPath);
+})();
+
+async function writeToPackage(fileName, content) {
+ const toPath = path.join(packagePath, fileName);
+ cleanupPaths.push(toPath);
+ console.error(`- generating: //${path.relative(ROOT_PATH, toPath)}`);
+ await writeFileAsync(toPath, content);
+}
+
+async function copyToPackage(fileOrDirectoryName) {
+ const fromPath = path.join(ROOT_PATH, fileOrDirectoryName);
+ const toPath = path.join(packagePath, fileOrDirectoryName);
+ cleanupPaths.push(toPath);
+ console.error(`- copying: //${path.relative(ROOT_PATH, fromPath)} -> //${path.relative(ROOT_PATH, toPath)}`);
+ await cpAsync(fromPath, toPath);
+}
+
+function usage() {
+ return `
+usage: ${SCRIPT_NAME} <package-name> <output-path> [--no-cleanup]
+
+Creates a .tgz of the package and saves it at the given output path
+
+ --no-cleanup skip cleaning up generated files from package directory
+
+Example:
+ ${SCRIPT_NAME} playwright ./playwright.tgz
+`;
+}
+
diff --git a/packages/playwright-chromium/browsers.json b/packages/playwright-chromium/browsers.json
deleted file mode 100644
index 14e5791c45..0000000000
--- a/packages/playwright-chromium/browsers.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "browsers": [
- {
- "name": "chromium",
- "revision": "767256"
- }
- ]
-}
diff --git a/packages/playwright-chromium/index.js b/packages/playwright-chromium/index.js
index 238612395c..bcc6ecaa3d 100644
--- a/packages/playwright-chromium/index.js
+++ b/packages/playwright-chromium/index.js
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-const { Playwright } = require('playwright-core/lib/server/playwright');
+const { Playwright } = require('./lib/server/playwright');
module.exports = new Playwright(__dirname, require('./browsers.json')['browsers']);
diff --git a/packages/playwright-chromium/install.js b/packages/playwright-chromium/install.js
index b249271f2b..13c8ccee30 100644
--- a/packages/playwright-chromium/install.js
+++ b/packages/playwright-chromium/install.js
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-const { installBrowsersWithProgressBar } = require('playwright-core/lib/install/installer');
+const { installBrowsersWithProgressBar } = require('./lib/install/installer');
installBrowsersWithProgressBar(__dirname);
diff --git a/packages/playwright-chromium/package.json b/packages/playwright-chromium/package.json
deleted file mode 100644
index 59a7fb1e11..0000000000
--- a/packages/playwright-chromium/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "playwright-chromium",
- "version": "1.0.0-post",
- "description": "A high-level API to automate Chromium",
- "repository": "github:Microsoft/playwright",
- "homepage": "https://playwright.dev",
- "main": "index.js",
- "scripts": {
- "install": "node install.js"
- },
- "author": {
- "name": "Microsoft Corporation"
- },
- "license": "Apache-2.0",
- "dependencies": {
- "playwright-core": "=1.0.0-post"
- }
-}
diff --git a/packages/playwright-core/README.md b/packages/playwright-core/README.md
new file mode 100644
index 0000000000..422b3739f5
--- /dev/null
+++ b/packages/playwright-core/README.md
@@ -0,0 +1,3 @@
+# playwright-core
+
+This package contains the no-browser flavor of [Playwright](http://github.com/microsoft/playwright).
diff --git a/packages/playwright-core/install.js b/packages/playwright-core/install.js
new file mode 100644
index 0000000000..955ab6083e
--- /dev/null
+++ b/packages/playwright-core/install.js
@@ -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.
+ */
+
+/* NOTE: playwright-core does not install browsers by design. */
diff --git a/packages/playwright-firefox/browsers.json b/packages/playwright-firefox/browsers.json
deleted file mode 100644
index 5521308109..0000000000
--- a/packages/playwright-firefox/browsers.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "browsers": [
- {
- "name": "firefox",
- "revision": "1094"
- }
- ]
-}
diff --git a/packages/playwright-firefox/index.js b/packages/playwright-firefox/index.js
index 238612395c..bcc6ecaa3d 100644
--- a/packages/playwright-firefox/index.js
+++ b/packages/playwright-firefox/index.js
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-const { Playwright } = require('playwright-core/lib/server/playwright');
+const { Playwright } = require('./lib/server/playwright');
module.exports = new Playwright(__dirname, require('./browsers.json')['browsers']);
diff --git a/packages/playwright-firefox/install.js b/packages/playwright-firefox/install.js
index b249271f2b..13c8ccee30 100644
--- a/packages/playwright-firefox/install.js
+++ b/packages/playwright-firefox/install.js
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-const { installBrowsersWithProgressBar } = require('playwright-core/lib/install/installer');
+const { installBrowsersWithProgressBar } = require('./lib/install/installer');
installBrowsersWithProgressBar(__dirname);
diff --git a/packages/playwright-firefox/package.json b/packages/playwright-firefox/package.json
deleted file mode 100644
index 2d43ff37e3..0000000000
--- a/packages/playwright-firefox/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "playwright-firefox",
- "version": "1.0.0-post",
- "description": "A high-level API to automate Firefox",
- "repository": "github:Microsoft/playwright",
- "homepage": "https://playwright.dev",
- "main": "index.js",
- "scripts": {
- "install": "node install.js"
- },
- "author": {
- "name": "Microsoft Corporation"
- },
- "license": "Apache-2.0",
- "dependencies": {
- "playwright-core": "=1.0.0-post"
- }
-}
diff --git a/packages/playwright-webkit/browsers.json b/packages/playwright-webkit/browsers.json
deleted file mode 100644
index 4a7d7f06f7..0000000000
--- a/packages/playwright-webkit/browsers.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "browsers": [
- {
- "name": "webkit",
- "revision": "1241"
- }
- ]
-}
diff --git a/packages/playwright-webkit/index.js b/packages/playwright-webkit/index.js
index 238612395c..bcc6ecaa3d 100644
--- a/packages/playwright-webkit/index.js
+++ b/packages/playwright-webkit/index.js
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-const { Playwright } = require('playwright-core/lib/server/playwright');
+const { Playwright } = require('./lib/server/playwright');
module.exports = new Playwright(__dirname, require('./browsers.json')['browsers']);
diff --git a/packages/playwright-webkit/install.js b/packages/playwright-webkit/install.js
index b249271f2b..13c8ccee30 100644
--- a/packages/playwright-webkit/install.js
+++ b/packages/playwright-webkit/install.js
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-const { installBrowsersWithProgressBar } = require('playwright-core/lib/install/installer');
+const { installBrowsersWithProgressBar } = require('./lib/install/installer');
installBrowsersWithProgressBar(__dirname);
diff --git a/packages/playwright-webkit/package.json b/packages/playwright-webkit/package.json
deleted file mode 100644
index 6f96ae7404..0000000000
--- a/packages/playwright-webkit/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "playwright-webkit",
- "version": "1.0.0-post",
- "description": "A high-level API to automate WebKit",
- "repository": "github:Microsoft/playwright",
- "homepage": "https://playwright.dev",
- "main": "index.js",
- "scripts": {
- "install": "node install.js"
- },
- "author": {
- "name": "Microsoft Corporation"
- },
- "license": "Apache-2.0",
- "dependencies": {
- "playwright-core": "=1.0.0-post"
- }
-}
diff --git a/packages/playwright/.gitignore b/packages/playwright/.gitignore
deleted file mode 100644
index 0cfb901530..0000000000
--- a/packages/playwright/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# copied from the root readme
-README.md
diff --git a/packages/playwright/.npmignore b/packages/playwright/.npmignore
deleted file mode 100644
index 7d2822f2fe..0000000000
--- a/packages/playwright/.npmignore
+++ /dev/null
@@ -1 +0,0 @@
-# empty to not exclude things in gitignore
\ No newline at end of file
diff --git a/packages/playwright/index.js b/packages/playwright/index.js
index 238612395c..bcc6ecaa3d 100644
--- a/packages/playwright/index.js
+++ b/packages/playwright/index.js
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-const { Playwright } = require('playwright-core/lib/server/playwright');
+const { Playwright } = require('./lib/server/playwright');
module.exports = new Playwright(__dirname, require('./browsers.json')['browsers']);
diff --git a/packages/playwright/install.js b/packages/playwright/install.js
index b249271f2b..13c8ccee30 100644
--- a/packages/playwright/install.js
+++ b/packages/playwright/install.js
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-const { installBrowsersWithProgressBar } = require('playwright-core/lib/install/installer');
+const { installBrowsersWithProgressBar } = require('./lib/install/installer');
installBrowsersWithProgressBar(__dirname);
diff --git a/packages/playwright/package.json b/packages/playwright/package.json
deleted file mode 100644
index 64c3dbfccd..0000000000
--- a/packages/playwright/package.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "playwright",
- "version": "1.0.0-post",
- "description": "A high-level API to automate web browsers",
- "repository": "github:Microsoft/playwright",
- "homepage": "https://playwright.dev",
- "main": "index.js",
- "scripts": {
- "install": "node install.js",
- "prepublishOnly": "cp ../../README.md ."
- },
- "author": {
- "name": "Microsoft Corporation"
- },
- "license": "Apache-2.0",
- "dependencies": {
- "playwright-core": "=1.0.0-post"
- }
-}
diff --git a/test/installation-tests/installation-tests.sh b/test/installation-tests/installation-tests.sh
index aed1172d55..68045b1ace 100755
--- a/test/installation-tests/installation-tests.sh
+++ b/test/installation-tests/installation-tests.sh
@@ -5,31 +5,22 @@ set +x
trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)"
-# 1. Pack all packages.
-
rm -rf ./output
mkdir ./output
cd ./output
-npm pack ../../..
-npm pack ../../../packages/playwright
-npm pack ../../../packages/playwright-chromium
-npm pack ../../../packages/playwright-webkit
-npm pack ../../../packages/playwright-firefox
-
# cleanup environment
unset PLAYWRIGHT_DOWNLOAD_HOST
unset PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD
export PLAYWRIGHT_BROWSERS_PATH=0
-# There is no option to specify output for `npm pack`, but the format is
-# fixed.
-PACKAGE_VERSION=$(node -e 'console.log(require("../../../package.json").version)')
-PLAYWRIGHT_CORE_TGZ="$(pwd -P)/playwright-core-${PACKAGE_VERSION}.tgz"
-PLAYWRIGHT_TGZ="$(pwd -P)/playwright-${PACKAGE_VERSION}.tgz"
-PLAYWRIGHT_CHROMIUM_TGZ="$(pwd -P)/playwright-chromium-${PACKAGE_VERSION}.tgz"
-PLAYWRIGHT_WEBKIT_TGZ="$(pwd -P)/playwright-webkit-${PACKAGE_VERSION}.tgz"
-PLAYWRIGHT_FIREFOX_TGZ="$(pwd -P)/playwright-firefox-${PACKAGE_VERSION}.tgz"
+# Pack all packages and put them in our output folder.
+PACKAGE_BUILDER="../../../packages/build_package.js"
+PLAYWRIGHT_CORE_TGZ="$(node ${PACKAGE_BUILDER} playwright-core ./playwright-core.tgz)"
+PLAYWRIGHT_TGZ="$(node ${PACKAGE_BUILDER} playwright ./playwright.tgz)"
+PLAYWRIGHT_CHROMIUM_TGZ="$(node ${PACKAGE_BUILDER} playwright-chromium ./playwright-chromium.tgz)"
+PLAYWRIGHT_WEBKIT_TGZ="$(node ${PACKAGE_BUILDER} playwright-webkit ./playwright-webkit.tgz)"
+PLAYWRIGHT_FIREFOX_TGZ="$(node ${PACKAGE_BUILDER} playwright-firefox ./playwright-firefox.tgz)"
SANITY_JS="$(pwd -P)/../sanity.js"
TEST_ROOT="$(pwd -P)"
diff --git a/utils/publish_all_packages.sh b/utils/publish_all_packages.sh
index f39688b29b..62a35c4df8 100755
--- a/utils/publish_all_packages.sh
+++ b/utils/publish_all_packages.sh
@@ -2,7 +2,16 @@
set -e
set -x
-trap "cd $(pwd -P)" EXIT
+function cleanup {
+ # Cleanup all possibly created package tars.
+ [[ ! -z "${PLAYWRIGHT_TGZ}" ]] && rm -rf "${PLAYWRIGHT_TGZ}"
+ [[ ! -z "${PLAYWRIGHT_CORE_TGZ}" ]] && rm -rf "${PLAYWRIGHT_CORE_TGZ}"
+ [[ ! -z "${PLAYWRIGHT_WEBKIT_TGZ}" ]] && rm -rf "${PLAYWRIGHT_WEBKIT_TGZ}"
+ [[ ! -z "${PLAYWRIGHT_FIREFOX_TGZ}" ]] && rm -rf "${PLAYWRIGHT_FIREFOX_TGZ}"
+ [[ ! -z "${PLAYWRIGHT_CHROMIUM_TGZ}" ]] && rm -rf "${PLAYWRIGHT_CHROMIUM_TGZ}"
+}
+
+trap "cleanup; cd $(pwd -P)" EXIT
cd "$(dirname $0)"
if [[ $1 == "--help" ]]; then
@@ -66,11 +75,16 @@ else
exit 1
fi
-npm run clean
-npm publish . --tag="${NPM_PUBLISH_TAG}"
-npm publish packages/playwright-firefox --tag="${NPM_PUBLISH_TAG}"
-npm publish packages/playwright-webkit --tag="${NPM_PUBLISH_TAG}"
-npm publish packages/playwright-chromium --tag="${NPM_PUBLISH_TAG}"
-npm publish packages/playwright --tag="${NPM_PUBLISH_TAG}"
+PLAYWRIGHT_TGZ="$(node ./packages/build_package.js playwright ./playwright.tgz)"
+PLAYWRIGHT_CORE_TGZ="$(node ./packages/build_package.js playwright-core ./playwright-core.tgz)"
+PLAYWRIGHT_WEBKIT_TGZ="$(node ./packages/build_package.js playwright-webkit ./playwright-webkit.tgz)"
+PLAYWRIGHT_FIREFOX_TGZ="$(node ./packages/build_package.js playwright-firefox ./playwright-firefox.tgz)"
+PLAYWRIGHT_CHROMIUM_TGZ="$(node ./packages/build_package.js playwright-chromium ./playwright-chromium.tgz)"
+
+npm publish ${PLAYWRIGHT_TGZ} --tag="${NPM_PUBLISH_TAG}" --dry-run
+npm publish ${PLAYWRIGHT_CORE_TGZ} --tag="${NPM_PUBLISH_TAG}" --dry-run
+npm publish ${PLAYWRIGHT_WEBKIT_TGZ} --tag="${NPM_PUBLISH_TAG}" --dry-run
+npm publish ${PLAYWRIGHT_FIREFOX_TGZ} --tag="${NPM_PUBLISH_TAG}" --dry-run
+npm publish ${PLAYWRIGHT_CHROMIUM_TGZ} --tag="${NPM_PUBLISH_TAG}" --dry-run
echo "Done."
diff --git a/utils/update_version.js b/utils/update_version.js
index 595dcc4440..b0492d2915 100755
--- a/utils/update_version.js
+++ b/utils/update_version.js
@@ -59,18 +59,10 @@ if (version === '--next') {
version = version.substring(1);
}
-
updatePackage(path.join(__dirname, '..', 'package.json'), packageJSON => {
packageJSON.version = version;
});
-for (const packageName of ['playwright-chromium', 'playwright-firefox', 'playwright-webkit', 'playwright']) {
- updatePackage(path.join(__dirname, '..', 'packages', packageName, 'package.json'), packageJSON => {
- packageJSON.version = version;
- packageJSON.dependencies['playwright-core'] = `=${version}`;
- });
-}
-
function updatePackage(packageJSONPath, transform) {
console.log(`Updating ${packageJSONPath} to ${version}.`);
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf8'));