chore: migrate to monorepo (#9421)

This commit is contained in:
Joel Einbinder 2021-10-11 10:52:17 -04:00 committed by GitHub
parent 8d1537c5aa
commit c89d5a50dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
521 changed files with 4752 additions and 8180 deletions

View File

@ -1,9 +1,9 @@
test/assets/modernizr.js
lib/
/packages/*/lib/
*.js
src/generated/*
src/third_party/
/types/*
/packages/playwright-core/src/generated/*
/packages/playwright-core/src/third_party/
/packages/playwright-core/types/*
/index.d.ts
utils/generate_types/overrides.d.ts
utils/generate_types/test/test.ts

View File

@ -19,9 +19,10 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: npm run lint
- name: Verify clean tree
run: |

View File

@ -21,6 +21,8 @@ jobs:
with:
node-version: 14
cache: 'npm'
- run: npm i -g npm@7
- run: npm ci
- run: npm i --no-save @playwright/test
- run: npm run build
- run: npm run test

View File

@ -17,9 +17,10 @@ jobs:
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: node utils/build/update_canary_version.js --commit-timestamp
- run: utils/build/build-playwright-driver.sh
- run: utils/build/upload-playwright-driver.sh

View File

@ -19,9 +19,10 @@ jobs:
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: node utils/build/update_canary_version.js --today-date
if: contains(github.ref, 'master') && github.event_name != 'workflow_dispatch'
- run: node utils/build/update_canary_version.js --commit-timestamp

View File

@ -15,9 +15,10 @@ jobs:
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: utils/publish_all_packages.sh --release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@ -32,9 +33,10 @@ jobs:
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: utils/build/build-playwright-driver.sh
- run: utils/build/upload-playwright-driver.sh
env:

View File

@ -12,10 +12,11 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- name: Install dependencies
run: node lib/cli/cli install-deps
run: npx playwright install-deps
- name: Roll to new revision
run: |
./utils/roll_browser.js ${{ github.event.client_payload.browser }} ${{ github.event.client_payload.revision }}

View File

@ -39,6 +39,7 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 14
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- name: Build

View File

@ -24,12 +24,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=${{ matrix.browser }}
env:
PWTEST_VIDEO: 1
@ -53,11 +54,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 14
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- name: Create Android Emulator
run: utils/avd_recreate.sh
- name: Start Android Emulator

View File

@ -32,12 +32,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=${{ matrix.browser }}
- run: node tests/config/checkCoverage.js ${{ matrix.browser }}
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
@ -60,11 +61,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
- run: npm run build
- run: node lib/cli/cli install --with-deps
- run: npx playwright install --with-deps
- run: npm run ttest
if: matrix.os != 'ubuntu-latest'
- run: xvfb-run npm run ttest

View File

@ -33,12 +33,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=${{ matrix.browser }}
- run: node tests/config/checkCoverage.js ${{ matrix.browser }}
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
@ -62,12 +63,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: npm run test -- --project=${{ matrix.browser }}
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always()
@ -89,12 +91,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: npm run test -- --project=${{ matrix.browser }}
shell: bash
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
@ -121,12 +124,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
- run: npm run build
- run: node lib/cli/cli install-deps
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash packages/installation-tests/installation-tests.sh
- run: npx playwright install-deps
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash installation-tests/installation-tests.sh
headful_linux:
name: "Headful Linux"
@ -140,12 +144,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=${{ matrix.browser }}
if: ${{ always() }}
env:
@ -170,12 +175,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chromium
- run: npx playwright install --with-deps chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest
env:
PWTEST_MODE: ${{ matrix.mode }}
@ -199,12 +205,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=${{ matrix.browser }}
env:
PWTEST_TRACE: 1
@ -219,11 +226,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome
- run: npx playwright install --with-deps chrome
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest
env:
PWTEST_CHANNEL: chrome
@ -243,11 +251,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome
- run: npx playwright install --with-deps chrome
- run: npm run ctest
shell: bash
env:
@ -269,11 +278,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome
- run: npx playwright install --with-deps chrome
- run: npm run ctest
env:
PWTEST_CHANNEL: chrome
@ -293,11 +303,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps firefox-beta chromium
- run: npx playwright install --with-deps firefox-beta chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ftest
env:
PWTEST_CHANNEL: firefox-beta
@ -317,11 +328,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps firefox-beta chromium
- run: npx playwright install --with-deps firefox-beta chromium
- run: npm run ftest
shell: bash
env:
@ -343,11 +355,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps firefox-beta chromium
- run: npx playwright install --with-deps firefox-beta chromium
- run: npm run ftest
env:
PWTEST_CHANNEL: firefox-beta
@ -367,11 +380,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge
- run: npx playwright install --with-deps msedge
- run: npm run ctest
env:
PWTEST_CHANNEL: msedge
@ -392,11 +406,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge
- run: npx playwright install --with-deps msedge
- run: npm run ctest
shell: bash
env:
@ -415,11 +430,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-beta
- run: npx playwright install --with-deps msedge-beta
- run: npm run ctest
env:
PWTEST_CHANNEL: msedge-beta
@ -439,11 +455,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-beta
- run: npx playwright install --with-deps msedge-beta
- run: npm run ctest
shell: bash
env:
@ -462,11 +479,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-beta
- run: npx playwright install --with-deps msedge-beta
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest
env:
PWTEST_CHANNEL: msedge-beta
@ -486,11 +504,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-dev
- run: npx playwright install --with-deps msedge-dev
- run: npm run ctest
env:
PWTEST_CHANNEL: msedge-dev
@ -510,11 +529,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-dev
- run: npx playwright install --with-deps msedge-dev
- run: npm run ctest
shell: bash
env:
@ -533,11 +553,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-dev
- run: npx playwright install --with-deps msedge-dev
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest
env:
PWTEST_CHANNEL: msedge-dev
@ -557,11 +578,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome-beta
- run: npx playwright install --with-deps chrome-beta
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest
env:
PWTEST_CHANNEL: chrome-beta
@ -581,11 +603,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome-beta
- run: npx playwright install --with-deps chrome-beta
- run: npm run ctest
shell: bash
env:
@ -607,11 +630,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome-beta
- run: npx playwright install --with-deps chrome-beta
- run: npm run ctest
env:
PWTEST_CHANNEL: chrome-beta
@ -631,11 +655,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chromium
- run: npx playwright install --with-deps chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run etest
- run: node tests/config/checkCoverage.js electron
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
@ -654,8 +679,9 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: node utils/build/update_canary_version.js --today-date
- run: utils/build/build-playwright-driver.sh

5
.gitignore vendored
View File

@ -9,7 +9,7 @@ node_modules/
.vscode
.idea
yarn.lock
/src/generated/*
/packages/playwright-core/src/generated/*
lib/
drivers/
.android-sdk/
@ -20,3 +20,6 @@ nohup.out
allure*
playwright-report
/demo/
/packages/*/LICENSE
/packages/*/NOTICE
/packages/playwright/README.md

View File

@ -13,6 +13,6 @@
],
"ignore": [
"**/*.d.ts",
"src/injected/**/*"
"packages/playwright-core/src/injected/**/*"
]
}

View File

@ -17,7 +17,7 @@
// This file is only run when someone installs via the github repo
const {execSync} = require('child_process');
const { execSync } = require('child_process');
const path = require('path');
console.log(`Updating test runner...`);
@ -30,18 +30,9 @@ try {
process.exit(1);
}
console.log(`Rebuilding installer...`);
try {
execSync('npm run build-installer', {
stdio: ['inherit', 'inherit', 'inherit'],
});
} catch (e) {
process.exit(1);
}
console.log(`Downloading browsers...`);
const { installDefaultBrowsersForNpmInstall } = require('./lib/utils/registry');
installDefaultBrowsersForNpmInstall().catch(e => {
const { installDefaultBrowsersForNpmInstall } = require('./packages/playwright-core/lib/utils/registry');
installDefaultBrowsersForNpmInstall().catch(e => {
console.error(`Failed to install browsers, caused by\n${e.stack}`);
process.exit(1);
});

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
const { start } = require('playwright/lib/outofprocess.js');
const { start } = require('playwright-core/lib/outofprocess');
(async () => {
const playwright = await start();

View File

@ -16,7 +16,7 @@
import { chromium, firefox, webkit, selectors, devices, errors } from 'playwright-chromium';
import playwright from 'playwright-chromium';
import errorsFile from 'playwright-chromium/lib/utils/errors.js';
import errorsFile from 'playwright-core/lib/utils/errors';
import testESM from './esm.mjs';
testESM({ chromium, firefox, webkit, selectors, devices, errors, playwright, errorsFile }, [chromium]);

View File

@ -16,7 +16,7 @@
import { chromium, firefox, webkit, selectors, devices, errors } from 'playwright-firefox';
import playwright from 'playwright-firefox';
import errorsFile from 'playwright-firefox/lib/utils/errors.js';
import errorsFile from 'playwright-core/lib/utils/errors';
import testESM from './esm.mjs';
testESM({ chromium, firefox, webkit, selectors, devices, errors, playwright, errorsFile }, [firefox]);

View File

@ -17,7 +17,7 @@
import { chromium, firefox, webkit, selectors, devices, errors, test, expect } from '@playwright/test';
import * as playwright from '@playwright/test';
import defaultExport from '@playwright/test';
import errorsFile from '@playwright/test/lib/utils/errors.js';
import errorsFile from 'playwright-core/lib/utils/errors';
import testESM from './esm.mjs';
if (defaultExport !== test) {

View File

@ -16,7 +16,7 @@
import { chromium, firefox, webkit, selectors, devices, errors } from 'playwright-webkit';
import playwright from 'playwright-webkit';
import errorsFile from 'playwright-webkit/lib/utils/errors.js';
import errorsFile from 'playwright-core/lib/utils/errors';
import testESM from './esm.mjs';
testESM({ chromium, firefox, webkit, selectors, devices, errors, playwright, errorsFile }, [webkit]);

View File

@ -16,7 +16,7 @@
import { chromium, firefox, webkit, selectors, devices, errors } from 'playwright';
import playwright from 'playwright';
import errorsFile from 'playwright/lib/utils/errors.js';
import errorsFile from 'playwright-core/lib/utils/errors';
import testESM from './esm.mjs';
testESM({ chromium, firefox, webkit, selectors, devices, errors, playwright, errorsFile }, [chromium, firefox, webkit]);

View File

@ -16,7 +16,7 @@ export PLAYWRIGHT_BROWSERS_PATH=0
# Pack all packages and put them in our output folder.
echo "Building packages..."
PACKAGE_BUILDER="../../../packages/build_package.js"
PACKAGE_BUILDER="../../utils/pack_package.js"
PLAYWRIGHT_CORE_TGZ="$(node ${PACKAGE_BUILDER} playwright-core ./playwright-core.tgz)"
echo "playwright-core built"
PLAYWRIGHT_TGZ="$(node ${PACKAGE_BUILDER} playwright ./playwright.tgz)"
@ -34,7 +34,7 @@ SCRIPTS_PATH="$(pwd -P)/.."
TEST_ROOT="/tmp/playwright-installation-tests"
rm -rf "${TEST_ROOT}"
mkdir -p "${TEST_ROOT}"
NODE_VERSION="$(node --version)"
NODE_VERSION=$(node -e "console.log(process.version.slice(1).split('.')[0])")
function copy_test_scripts {
cp "${SCRIPTS_PATH}/inspector-custom-executable.js" .
@ -74,17 +74,12 @@ function run_tests {
test_playwright_cli_install_should_work
test_playwright_cli_codegen_should_work
test_playwright_driver_should_work
# npm v7 that comes with Node v16 swallows output from install scripts,
# so the following tests won't work.
# See discussion at https://github.com/npm/cli/issues/1651
if [[ "${NODE_VERSION}" != *"v16."* ]]; then
test_skip_browser_download
test_skip_browser_download_inspect_with_custom_executable
test_playwright_should_work
test_playwright_chromium_should_work
test_playwright_webkit_should_work
test_playwright_firefox_should_work
fi
test_skip_browser_download
test_skip_browser_download_inspect_with_custom_executable
test_playwright_should_work
test_playwright_chromium_should_work
test_playwright_webkit_should_work
test_playwright_firefox_should_work
}
function test_screencast {
@ -92,6 +87,7 @@ function test_screencast {
copy_test_scripts
local BROWSERS="$(pwd -P)/browsers"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_TGZ}
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_FIREFOX_TGZ}
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_WEBKIT_TGZ}
@ -111,7 +107,7 @@ function test_typescript_types {
copy_test_scripts
# install all packages.
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_FIREFOX_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_WEBKIT_TGZ}
@ -139,6 +135,7 @@ function test_playwright_global_installation {
initialize_test "${FUNCNAME[0]}"
local BROWSERS="$(pwd -P)/browsers"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_TGZ}
if [[ ! -d "${BROWSERS}" ]]; then
echo "Directory for shared browsers was not created!"
@ -156,6 +153,7 @@ function test_playwright_global_installation {
function test_playwright_global_installation_cross_package {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_FIREFOX_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_WEBKIT_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_CHROMIUM_TGZ}
@ -185,6 +183,7 @@ function test_playwright_global_installation_subsequent_installs {
local BROWSERS="$(pwd -P)/browsers"
mkdir install-1 && pushd install-1 && npm init -y
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_TGZ}
# Note: the `npm install` would not actually crash, the error
# is merely logged to the console. To reproduce the error, we should make
@ -199,7 +198,8 @@ function test_playwright_global_installation_subsequent_installs {
function test_skip_browser_download {
initialize_test "${FUNCNAME[0]}"
OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install --foreground-script ${PLAYWRIGHT_TGZ})
if [[ "${OUTPUT}" != *"Skipping browsers download because"* ]]; then
echo "missing log message that browsers download is skipped"
exit 1
@ -217,7 +217,8 @@ function test_skip_browser_download_inspect_with_custom_executable {
initialize_test "${FUNCNAME[0]}"
copy_test_scripts
OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install --foreground-script ${PLAYWRIGHT_TGZ})
if [[ "${OUTPUT}" != *"Skipping browsers download because"* ]]; then
echo "missing log message that browsers download is skipped"
exit 1
@ -242,7 +243,8 @@ function test_skip_browser_download_inspect_with_custom_executable {
function test_playwright_should_work {
initialize_test "${FUNCNAME[0]}"
OUTPUT=$(npm install ${PLAYWRIGHT_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(npm install --foreground-script ${PLAYWRIGHT_TGZ})
if [[ "${OUTPUT}" != *"chromium"* ]]; then
echo "ERROR: should download chromium"
exit 1
@ -259,7 +261,7 @@ function test_playwright_should_work {
echo "Running sanity.js"
node sanity.js playwright
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
if [[ ${NODE_VERSION} -ge 14 ]]; then
echo "Running esm.js"
node esm-playwright.mjs
fi
@ -275,6 +277,7 @@ function test_playwright_should_work {
function test_playwright_should_work_with_relative_home_path {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_BROWSERS_PATH="" HOME=. npm install ${PLAYWRIGHT_TGZ}
copy_test_scripts
echo "Running sanity.js"
@ -289,6 +292,7 @@ function test_playwright_should_work_with_relative_browsers_path {
# Make sure that browsers path is resolved relative to the `npm install` call location.
mkdir foo
cd foo
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_BROWSERS_PATH="../relative" npm install ${PLAYWRIGHT_TGZ}
cd ..
@ -301,7 +305,8 @@ function test_playwright_should_work_with_relative_browsers_path {
function test_playwright_chromium_should_work {
initialize_test "${FUNCNAME[0]}"
OUTPUT=$(npm install ${PLAYWRIGHT_CHROMIUM_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(npm install --foreground-script ${PLAYWRIGHT_CHROMIUM_TGZ})
if [[ "${OUTPUT}" != *"chromium"* ]]; then
echo "ERROR: should download chromium"
exit 1
@ -318,7 +323,7 @@ function test_playwright_chromium_should_work {
echo "Running sanity.js"
node sanity.js playwright-chromium
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
if [[ ${NODE_VERSION} -ge 14 ]]; then
echo "Running esm.js"
node esm-playwright-chromium.mjs
fi
@ -329,7 +334,8 @@ function test_playwright_chromium_should_work {
function test_playwright_webkit_should_work {
initialize_test "${FUNCNAME[0]}"
OUTPUT=$(npm install ${PLAYWRIGHT_WEBKIT_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(npm install --foreground-script ${PLAYWRIGHT_WEBKIT_TGZ})
if [[ "${OUTPUT}" == *"chromium"* ]]; then
echo "ERROR: should not download chromium"
exit 1
@ -346,7 +352,7 @@ function test_playwright_webkit_should_work {
echo "Running sanity.js"
node sanity.js playwright-webkit
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
if [[ ${NODE_VERSION} -ge 14 ]]; then
echo "Running esm.js"
node esm-playwright-webkit.mjs
fi
@ -357,7 +363,8 @@ function test_playwright_webkit_should_work {
function test_playwright_firefox_should_work {
initialize_test "${FUNCNAME[0]}"
OUTPUT=$(npm install ${PLAYWRIGHT_FIREFOX_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(npm install --foreground-script ${PLAYWRIGHT_FIREFOX_TGZ})
if [[ "${OUTPUT}" == *"chromium"* ]]; then
echo "ERROR: should not download chromium"
exit 1
@ -374,7 +381,7 @@ function test_playwright_firefox_should_work {
echo "Running sanity.js"
node sanity.js playwright-firefox
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
if [[ ${NODE_VERSION} -ge 14 ]]; then
echo "Running esm.js"
node esm-playwright-firefox.mjs
fi
@ -385,6 +392,7 @@ function test_playwright_firefox_should_work {
function test_playwright_validate_dependencies {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_TGZ}
copy_test_scripts
@ -400,6 +408,7 @@ function test_playwright_validate_dependencies {
function test_playwright_validate_dependencies_skip_executable_path {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_TGZ}
copy_test_scripts
@ -415,6 +424,7 @@ function test_playwright_validate_dependencies_skip_executable_path {
function test_playwright_electron_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
npm install electron@9.0
copy_test_scripts
@ -427,10 +437,11 @@ function test_playwright_electron_should_work {
function test_electron_types {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
npm install electron@9.0
npm install electron@12
npm install -D typescript@3.8
npm install -D @types/node@10.17
npm install -D @types/node@14
echo "import { Page, _electron, ElectronApplication, Electron } from 'playwright';" > "test.ts"
echo "Running tsc"
@ -442,9 +453,10 @@ function test_electron_types {
function test_android_types {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
npm install -D typescript@3.8
npm install -D @types/node@10.17
npm install -D @types/node@14
echo "import { AndroidDevice, _android, AndroidWebView, Page } from 'playwright';" > "test.ts"
echo "Running tsc"
@ -456,6 +468,7 @@ function test_android_types {
function test_playwright_cli_screenshot_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_TGZ}
echo "Running playwright screenshot"
@ -478,6 +491,7 @@ function test_playwright_cli_screenshot_should_work {
function test_playwright_cli_install_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
local BROWSERS="$(pwd -P)/browsers"
@ -531,6 +545,7 @@ function test_playwright_cli_install_should_work {
function test_playwright_cli_codegen_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_TGZ}
echo "Running playwright codegen"
@ -561,6 +576,7 @@ function test_playwright_cli_codegen_should_work {
function test_playwright_driver_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
echo "Running playwright install"
@ -576,6 +592,7 @@ function test_playwright_driver_should_work {
function test_playwright_test_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_TEST_TGZ}
copy_test_scripts

View File

@ -32,8 +32,8 @@ else if (process.argv[3])
const playwright = require(requireName);
// Requiring internals should work.
const errors = require(requireName + '/lib/utils/errors');
const registry = require(requireName + '/lib/utils/registry');
const errors = require('playwright-core/lib/utils/errors');
const registry = require('playwright-core/lib/utils/registry');
(async () => {
for (const browserType of success) {

7253
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,8 +8,12 @@
"engines": {
"node": ">=12"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"scripts": {
"basetest": "cross-env PWTEST_CLI_ALLOW_TEST_COMMAND=1 node ./lib/cli/cli test",
"basetest": "cross-env PWTEST_CLI_ALLOW_TEST_COMMAND=1 playwright test",
"ctest": "npm run basetest -- --config=tests/config/default.config.ts --project=chromium",
"ftest": "npm run basetest -- --config=tests/config/default.config.ts --project=firefox",
"wtest": "npm run basetest -- --config=tests/config/default.config.ts --project=webkit",
@ -19,11 +23,12 @@
"test": "npm run basetest -- --config=tests/config/default.config.ts",
"eslint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe --ext ts,tsx . || eslint --ext ts,tsx .",
"tsc": "tsc -p .",
"build-installer": "babel -s --extensions \".ts\" --out-dir lib/utils/ src/utils",
"build-installer": "babel -s --extensions \".ts\" --out-dir packages/playwright-core/lib/utils/ packages/playwright-core/src/utils",
"doc": "node utils/doclint/cli.js",
"lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && node utils/generate_channels.js && node utils/generate_types/ --check-clean && npm run test-types",
"flint": "concurrently -s all \"npm run eslint\" \"npm run tsc\" \"npm run doc\" \"npm run check-deps\" \"node utils/generate_channels.js\" \"node utils/generate_types/ --check-clean\" \"npm run test-types\"",
"clean": "rimraf lib && rimraf src/generated/",
"lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && node utils/generate_channels.js && node utils/generate_types/ --check-clean && npm run test-types && npm run lint-packages",
"lint-packages": "node utils/prepare_packages.js --check-clean",
"flint": "concurrently \"npm run eslint\" \"npm run tsc\" \"npm run doc\" \"npm run check-deps\" \"node utils/generate_channels.js\" \"node utils/generate_types/ --check-clean\" \"npm run test-types\" \"npm run lint-packages\"",
"clean": "rimraf packages/playwright-core/lib && rimraf packages/playwright-test/lib && rimraf packages/playwright-core/src/generated/",
"prepare": "node install-from-github.js",
"build": "node utils/build/build.js",
"watch": "node utils/build/build.js --watch --lint",
@ -32,57 +37,9 @@
"check-deps": "node utils/check_deps.js",
"build-android-driver": "./utils/build_android_driver.sh"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"bin": {
"playwright": "./lib/cli/cli.js"
},
"DEPS-NOTE": "Any non-test dependency must be added to the build_package.js script as well",
"dependencies": {
"@babel/code-frame": "^7.14.5",
"@babel/core": "^7.14.8",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-dynamic-import": "^7.14.5",
"@babel/plugin-proposal-export-namespace-from": "^7.14.5",
"@babel/plugin-proposal-logical-assignment-operators": "^7.14.5",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
"@babel/plugin-proposal-numeric-separator": "^7.14.5",
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
"@babel/plugin-proposal-private-methods": "^7.14.5",
"@babel/plugin-proposal-private-property-in-object": "^7.14.5",
"@babel/plugin-syntax-async-generators": "^7.8.4",
"@babel/plugin-syntax-json-strings": "^7.8.3",
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.14.5",
"@babel/preset-typescript": "^7.14.5",
"colors": "^1.4.0",
"commander": "^8.2.0",
"debug": "^4.1.1",
"expect": "^27.2.5",
"extract-zip": "^2.0.1",
"https-proxy-agent": "^5.0.0",
"jest-matcher-utils": "^27.2.5",
"jpeg-js": "^0.4.2",
"mime": "^2.4.6",
"minimatch": "^3.0.3",
"ms": "^2.1.2",
"open": "^8.2.1",
"pirates": "^4.0.1",
"pixelmatch": "^5.2.1",
"pngjs": "^5.0.0",
"progress": "^2.0.3",
"proper-lockfile": "^4.1.1",
"proxy-from-env": "^1.1.0",
"rimraf": "^3.0.2",
"source-map-support": "^0.4.18",
"stack-utils": "^2.0.3",
"ws": "^7.4.6",
"yauzl": "^2.10.0",
"yazl": "^2.5.1"
},
"workspaces": [
"packages/*"
],
"devDependencies": {
"@babel/cli": "^7.14.8",
"@babel/plugin-transform-typescript": "^7.14.6",

View File

@ -1,48 +0,0 @@
# Managing and Publishing Playwright Packages
## Overview
- Playwright ships multiple packages to NPM. All packages 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:
```bash
./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:
```bash
./packages/build_package.js playwright ./playwright.tgz --no-cleanup
ls ./packages/playwright # inspect the folder
```
## Testing packages
To test packages, use [`//packages/installation-tests/installation-tests.sh`](./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.

View File

@ -1,229 +0,0 @@
#!/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 os = require('os');
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 PLAYWRIGHT_CORE_FILES = ['bin', 'lib', 'types', 'NOTICE', 'LICENSE', ];
const PACKAGES = {
'playwright': {
description: 'A high-level API to automate web browsers',
browsers: ['chromium', 'firefox', 'webkit', 'ffmpeg'],
// We copy README.md additionally for Playwright so that it looks nice on NPM.
files: [...PLAYWRIGHT_CORE_FILES, 'README.md'],
},
'playwright-core': {
description: 'A high-level API to automate web browsers',
browsers: [],
files: PLAYWRIGHT_CORE_FILES,
},
'playwright-test': {
description: 'Playwright Test',
browsers: ['chromium', 'firefox', 'webkit', 'ffmpeg'],
files: PLAYWRIGHT_CORE_FILES,
name: '@playwright/test',
},
'playwright-webkit': {
description: 'A high-level API to automate WebKit',
browsers: ['webkit'],
files: PLAYWRIGHT_CORE_FILES,
},
'playwright-firefox': {
description: 'A high-level API to automate Firefox',
browsers: ['firefox'],
files: PLAYWRIGHT_CORE_FILES,
},
'playwright-chromium': {
description: 'A high-level API to automate Chromium',
browsers: ['chromium', 'ffmpeg'],
files: PLAYWRIGHT_CORE_FILES,
},
};
const DEPENDENCIES = [
'commander',
'debug',
'extract-zip',
'https-proxy-agent',
'jpeg-js',
'mime',
'pngjs',
'progress',
'proper-lockfile',
'proxy-from-env',
'rimraf',
'stack-utils',
'ws',
'yazl',
];
// 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);
}
const packageName = args[0];
const outputPath = path.resolve(args[1]);
const packagePath = path.join(__dirname, 'output', packageName);
const package = PACKAGES[packageName];
if (!package) {
console.log(`ERROR: unknown package ${packageName}`);
process.exit(1);
}
// 2. Setup cleanup if needed
if (!args.some(arg => arg === '--no-cleanup')) {
process.on('exit', () => {
rmSync(packagePath, {});
});
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);
});
}
(async () => {
// 3. Copy package files.
rmSync(packagePath, {});
fs.mkdirSync(packagePath, { recursive: true });
await copyToPackage(path.join(__dirname, 'common') + path.sep, packagePath + path.sep);
if (fs.existsSync(path.join(__dirname, packageName))) {
// Copy package-specific files, these can overwrite common ones.
await copyToPackage(path.join(__dirname, packageName) + path.sep, packagePath + path.sep);
}
for (const file of package.files)
await copyToPackage(path.join(ROOT_PATH, file), path.join(packagePath, file));
// 4. Generate package.json
const pwInternalJSON = require(path.join(ROOT_PATH, 'package.json'));
const depNames = packageName === 'playwright-test' ? Object.keys(pwInternalJSON.dependencies) : DEPENDENCIES;
const dependencies = {};
for (const dep of depNames) {
if (!pwInternalJSON.dependencies[dep])
throw new Error(`Dependecy ${dep} was removed from package.json, but not build_package.js`);
dependencies[dep] = pwInternalJSON.dependencies[dep];
}
await writeToPackage('package.json', JSON.stringify({
name: package.name || packageName,
version: pwInternalJSON.version,
description: package.description,
repository: pwInternalJSON.repository,
engines: pwInternalJSON.engines,
homepage: pwInternalJSON.homepage,
main: 'index.js',
bin: {
playwright: './lib/cli/cli.js',
},
exports: {
// Root import: we have a wrapper ES Module to support the following syntax.
// const { chromium } = require('playwright');
// import { chromium } from 'playwright';
'.': {
import: './index.mjs',
require: './index.js',
},
// Anything else can be required/imported by providing a relative path.
'./': './',
},
scripts: {
install: 'node install.js',
},
author: pwInternalJSON.author,
license: pwInternalJSON.license,
dependencies,
}, null, 2));
// 5. Generate browsers.json
const browsersJSON = require(path.join(ROOT_PATH, 'browsers.json'));
for (const browser of browsersJSON.browsers)
browser.installByDefault = package.browsers.includes(browser.name);
await writeToPackage('browsers.json', JSON.stringify(browsersJSON, null, 2));
// 6. Bake commit SHA into the package
const commitSHA = spawnSync('git', ['rev-parse', 'HEAD'], {cwd: __dirname, encoding: 'utf8'});
await writeToPackage('commitinfo', commitSHA.stdout.trim());
// 7. Run npm pack
const shell = os.platform() === 'win32';
const {stdout, stderr, status} = spawnSync('npm', ['pack'], {cwd: packagePath, encoding: 'utf8', shell});
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);
await writeFileAsync(toPath, content);
}
async function copyToPackage(fromPath, toPath) {
try {
fs.mkdirSync(path.dirname(toPath), { recursive: true });
} catch (e) {
// the folder might exist already
}
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
`;
}

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,6 @@
"test": "npx playwright test"
},
"devDependencies": {
"@playwright/test": "^1.15.0-next-alpha-sep-10-2021",
"@types/node": "^16.9.0",
"@vercel/ncc": "^0.30.0",
"enquirer": "^2.3.6",

View File

@ -26,7 +26,7 @@ type TestFixtures = {
};
type RunResult = {
exitCode: number,
exitCode: number|null,
dir: string,
stderr: string,
stdout: string,

View File

@ -1 +0,0 @@
output

View File

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

View File

@ -14,4 +14,4 @@
* limitations under the License.
*/
export * from './types/types';
export * from 'playwright-core';

View File

@ -14,4 +14,4 @@
* limitations under the License.
*/
module.exports = require('./lib/inprocess');
module.exports = require('playwright-core');

View File

@ -0,0 +1,18 @@
/**
* 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.
*/
export * from 'playwright-core';
import playwright from 'playwright-core';
export default playwright;

View File

@ -14,5 +14,6 @@
* limitations under the License.
*/
// Explicitly empty install.js to avoid touching browser registry at all.
// See https://github.com/microsoft/playwright/issues/4083
const { installBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');
installBrowsersForNpmInstall(['chromium', 'ffmpeg']);

View File

@ -0,0 +1,27 @@
{
"name": "playwright-chromium",
"version": "1.16.0-next",
"description": "A high-level API to automate web browsers",
"repository": "github:Microsoft/playwright",
"homepage": "https://playwright.dev",
"engines": {
"node": ">=12"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"exports": {
".": {
"import": "./index.mjs",
"require": "./index.js"
},
"./": "./"
},
"scripts": {
"install": "node install.js"
},
"dependencies": {
"playwright-core": "=1.16.0-next"
}
}

View File

@ -1,7 +1,3 @@
# NOTE: theoretically, we can remove this file, because we always create
# a directory for each package and only copy necessary files there.
# However, we keep it to double check the list of files.
#
# This ignores everything by default, except for package.json and LICENSE and README.md.
# See https://docs.npmjs.com/misc/developers
**/*
@ -37,7 +33,5 @@ lib/**/injected/
!NOTICE
# Include browser descriptors.
!browsers.json
# Include commit info
!commitinfo
# Include generated devices descriptors
!deviceDescriptorsSource.json

17
packages/playwright-core/cli.js Executable file
View File

@ -0,0 +1,17 @@
#!/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.
*/
module.exports = require('./lib/cli/cli');

View File

@ -0,0 +1,46 @@
{
"name": "playwright-core",
"version": "1.16.0-next",
"description": "A high-level API to automate web browsers",
"repository": "github:Microsoft/playwright",
"homepage": "https://playwright.dev",
"engines": {
"node": ">=12"
},
"scripts": {
"prepare": "babel --config-file ../../babel.config.json -s --extensions \".ts\" --out-dir lib/utils/ src/utils"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"exports": {
".": {
"import": "./index.mjs",
"require": "./index.js"
},
"./src/*": "./lib/*.js",
"./*": "./*.js"
},
"types": "types/types.d.ts",
"bin": {
"playwright": "./cli.js"
},
"dependencies": {
"commander": "^8.2.0",
"debug": "^4.1.1",
"extract-zip": "^2.0.1",
"https-proxy-agent": "^5.0.0",
"jpeg-js": "^0.4.2",
"mime": "^2.4.6",
"pngjs": "^5.0.0",
"progress": "^2.0.3",
"proper-lockfile": "^4.1.1",
"proxy-from-env": "^1.1.0",
"rimraf": "^3.0.2",
"stack-utils": "^2.0.3",
"ws": "^7.4.6",
"yazl": "^2.5.1",
"yauzl": "^2.10.0"
}
}

View File

@ -1,5 +1,5 @@
module.exports = {
"extends": "../.eslintrc.js",
"extends": "../../../.eslintrc.js",
/**
* ESLint rules
*

View File

@ -228,14 +228,9 @@ Examples:
if (!process.env.PW_CLI_TARGET_LANG) {
let playwrightTestPackagePath = null;
try {
const isLocal = packageJSON.name === '@playwright/test' || process.env.PWTEST_CLI_ALLOW_TEST_COMMAND;
if (isLocal) {
playwrightTestPackagePath = '../test/cli';
} else {
playwrightTestPackagePath = require.resolve('@playwright/test/lib/test/cli', {
paths: [__dirname, process.cwd()]
});
}
playwrightTestPackagePath = require.resolve('@playwright/test/lib/cli', {
paths: [__dirname, process.cwd()]
});
} catch {}
if (playwrightTestPackagePath) {

Some files were not shown because too many files have changed in this diff Show More