forked from microsoft/playwright
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: drop dependency on playwright-core in all our packages
This patch: - drops dependency on playwright-core in all our packages. Instead of the dependency, packages are now built with `//packages/build_package.sh` script. - unifies `browsers.json` - now there's a single `//browsers.json` file that is used to manage browser revisions. This patch temporary switches canary publishing to `--dryn-run` from CI/CD so that we can verify that it does sane things. We'll unify all our package management scripts under `//packages/` in a follow-up. Fixes microsoft#2268
- Loading branch information
1 parent
e658a3e
commit f1baa0c
Showing
26 changed files
with
255 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,4 @@ yarn.lock | |
/src/firefox/protocol.ts | ||
/src/webkit/protocol.ts | ||
lib/ | ||
playwright-*.tgz | ||
/types/* |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# 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.sh`](./build_package.sh) script. | ||
The script populates package folder with contents, and then uses `npm pack` to archive the folder. | ||
|
||
For example, to build `playwright` package and save result as `./playwright.tgz` file: | ||
|
||
```sh | ||
$ ./packages/build_package.sh 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.sh playwright ./playwright.tgz --no-cleanup | ||
$ ls ./packages/playwright # inspecting 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
#!/bin/bash | ||
set -e | ||
set +x | ||
|
||
if [[ "$(uname)" != "Darwin" && "$(uname)" != "Linux" ]]; then | ||
echo "ERROR: can't run on $(uname). This script is designed to work on Mac or Linux only" | ||
exit 1 | ||
fi | ||
|
||
|
||
# 1. Read arguments | ||
|
||
if [[ $1 == "--help" ]]; then | ||
echo "usage: $(basename $0) <package-name> <output-path> [--no-cleanup] [--no-build]" | ||
echo | ||
echo "Creates a .tgz of the package and saves it at the given output path" | ||
echo | ||
echo " --no-cleanup skip cleaning up generated files from package directory" | ||
echo " --no-build skip building root package. DANGER: make sure to build root package before running this script." | ||
echo | ||
echo "Example:" | ||
echo " $(basename $0) playwright $(pwd -P)/playwright.tgz" | ||
exit 1 | ||
fi | ||
|
||
if [[ $# < 1 ]]; then | ||
echo "Please specify package name, e.g. 'playwright' or 'playwright-chromium'." | ||
echo "Try running $(basename $0) --help" | ||
exit 1 | ||
fi | ||
PACKAGE_NAME="$1" | ||
|
||
if [[ $# < 2 ]]; then | ||
echo "Please specify output path" | ||
echo "Try running $(basename $0) --help" | ||
exit 1 | ||
fi | ||
OUTPUT_PATH=$(node -e "console.log(require('path').resolve('$2'))") | ||
|
||
NO_CLEANUP="" | ||
if [[ "$3" == "--no-cleanup" || "$4" == "--no-cleanup" ]]; then | ||
NO_CLEANUP="true" | ||
fi | ||
|
||
NO_BUILD="" | ||
if [[ "$3" == "--no-build" || "$4" == "--no-build" ]]; then | ||
NO_BUILD="true" | ||
fi | ||
|
||
|
||
# 2. Change directory to the script directory and setup cleanup hooks. | ||
|
||
CLEANUP_PATHS=() | ||
function do_cleanup { | ||
if [[ ! -z "${NO_CLEANUP}" ]]; then | ||
return | ||
fi | ||
for CLEANUP_PATH in "${CLEANUP_PATHS[@]}"; do | ||
rm -rf "${CLEANUP_PATH}" | ||
done | ||
} | ||
trap "do_cleanup; cd $(pwd -P)" EXIT | ||
cd "$(dirname $0)" | ||
|
||
|
||
# 3. Figure out package parameters. | ||
PACKAGE_PATH="$(pwd -P)/${PACKAGE_NAME}" | ||
PACKAGE_DESCRIPTION="" | ||
PACKAGE_BROWSERS="[]" | ||
if [[ "${PACKAGE_NAME}" == "playwright" ]]; then | ||
PACKAGE_DESCRIPTION="A high-level API to automate web browsers" | ||
PACKAGE_BROWSERS="['chromium', 'firefox', 'webkit']" | ||
|
||
# For Playwright, we need to copy README.md | ||
README_PATH="${PACKAGE_PATH}/README.md" | ||
CLEANUP_PATHS+=("${README_PATH}") | ||
cp ../README.md "${README_PATH}" | ||
elif [[ "${PACKAGE_NAME}" == "playwright-core" ]]; then | ||
PACKAGE_DESCRIPTION="A high-level API to automate web browsers" | ||
PACKAGE_BROWSERS="[]" | ||
elif [[ "${PACKAGE_NAME}" == "playwright-webkit" ]]; then | ||
PACKAGE_DESCRIPTION="A high-level API to automate Webkit" | ||
PACKAGE_BROWSERS="['webkit']" | ||
elif [[ "${PACKAGE_NAME}" == "playwright-firefox" ]]; then | ||
PACKAGE_DESCRIPTION="A high-level API to automate Firefox" | ||
PACKAGE_BROWSERS="['firefox']" | ||
elif [[ "${PACKAGE_NAME}" == "playwright-chromium" ]]; then | ||
PACKAGE_DESCRIPTION="A high-level API to automate Chromium" | ||
PACKAGE_BROWSERS="['chromium']" | ||
else | ||
echo "ERROR: unknown package '${PACKAGE_NAME}'" | ||
exit 1 | ||
fi | ||
|
||
|
||
# 4. Build root package unless --no-build was provided. | ||
|
||
if [[ -z "${NO_BUILD}" ]]; then | ||
npm run build | ||
else | ||
echo "Skippping BUILD because --no-build is provided" >/dev/stderr | ||
fi | ||
|
||
|
||
# 5. Copy library sources in the package. | ||
|
||
LIB_PATH="${PACKAGE_PATH}/lib" | ||
CLEANUP_PATHS+=("${LIB_PATH}") | ||
cp -r ../lib "${LIB_PATH}" | ||
|
||
|
||
# 6. Generate package.json for the package. | ||
|
||
PACKAGE_JSON_PATH="${PACKAGE_PATH}/package.json" | ||
CLEANUP_PATHS+=("${PACKAGE_JSON_PATH}") | ||
node -e "$(cat <<EOF | ||
const sourceJSON = require('../package.json'); | ||
const packageJSON = { | ||
"name": "${PACKAGE_NAME}", | ||
"version": sourceJSON.version, | ||
"description": "${PACKAGE_DESCRIPTION}", | ||
"repository": "github:Microsoft/playwright", | ||
"engines": sourceJSON.engines, | ||
"homepage": "https://playwright.dev", | ||
"main": "index.js", | ||
"scripts": { | ||
"install": "node install.js" | ||
}, | ||
"author": { | ||
"name": "Microsoft Corporation" | ||
}, | ||
"license": "Apache-2.0", | ||
"dependencies": sourceJSON.dependencies | ||
}; | ||
console.log(JSON.stringify(packageJSON, null, 2)); | ||
EOF | ||
)" > "${PACKAGE_JSON_PATH}" | ||
|
||
|
||
# 7. Generate browsers.json for the package. | ||
BROWSERS_JSON_PATH="${PACKAGE_PATH}/browsers.json" | ||
CLEANUP_PATHS+=("${BROWSERS_JSON_PATH}") | ||
node -e "$(cat <<EOF | ||
const browsersJSON = require('../browsers.json'); | ||
browsersJSON.browsers = browsersJSON.browsers.filter(browser => ${PACKAGE_BROWSERS}.includes(browser.name)); | ||
console.log(JSON.stringify(browsersJSON, null, 2)); | ||
EOF | ||
)" > "${BROWSERS_JSON_PATH}" | ||
|
||
|
||
# 8. Pack package and move to output directory. | ||
TAR_NAME=$(npm pack "${PACKAGE_PATH}") | ||
mv "${TAR_NAME}" "${OUTPUT_PATH}" | ||
echo "${OUTPUT_PATH}" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# playwright-core | ||
|
||
This package contains the no-browser flavor of [Playwright](http://github.com/microsoft/playwright). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. */ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.