Skip to content

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

fix(prepare): don't change package files on prepare (#11579)

Pavel Feldman136fab70417c
diff --git a/.github/workflows/infra.yml b/.github/workflows/infra.yml
index 420be3a1d9..3e753303d8 100644
--- a/.github/workflows/infra.yml
+++ b/.github/workflows/infra.yml
@@ -23,6 +23,7 @@ jobs:
- run: npm ci
- run: npm run build
- run: npx playwright install-deps
+ - run: npx playwright install
- run: npm run lint
- name: Verify clean tree
run: |
diff --git a/install-from-github.js b/install-from-github.js
deleted file mode 100644
index ca19654d37..0000000000
--- a/install-from-github.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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
-
-const { execSync } = require('child_process');
-const path = require('path');
-
-console.log(`Updating test runner...`);
-try {
- execSync('npm ci --save=false --fund=false --audit=false', {
- stdio: ['inherit', 'inherit', 'inherit'],
- cwd: path.join(__dirname, 'tests', 'playwright-test', 'stable-test-runner'),
- });
-} catch (e) {
- process.exit(1);
-}
-
-console.log(`Downloading browsers...`);
-const { installDefaultBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');
-installDefaultBrowsersForNpmInstall().catch(e => {
- console.error(`Failed to install browsers, caused by\n${e.stack}`);
- process.exit(1);
-});
-
-console.log(`Done. Use "npm run watch" to compile.`);
diff --git a/package.json b/package.json
index e01330b81c..5794dd468e 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,6 @@
"lint-tests": "node utils/lint_tests.js",
"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 lint-tests\" \"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",
"test-types": "node utils/generate_types/ && npx -p [email protected] tsc -p utils/generate_types/test/tsconfig.json && tsc -p ./tests/",
diff --git a/packages/playwright-chromium/install.js b/packages/playwright-chromium/install.js
index 7bfb93fa07..917aa2d5f8 100644
--- a/packages/playwright-chromium/install.js
+++ b/packages/playwright-chromium/install.js
@@ -14,6 +14,13 @@
* limitations under the License.
*/
-const { installBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');
+let install;
-installBrowsersForNpmInstall(['chromium', 'ffmpeg']);
+try {
+ install = require('playwright-core/lib/utils/registry').installBrowsersForNpmInstall;
+} catch (e) {
+ // Dev build, don't install browsers by default.
+}
+
+if (install)
+ install(['chromium', 'ffmpeg']);
diff --git a/packages/playwright-core/package.json b/packages/playwright-core/package.json
index b73822a1c8..baa6904edc 100644
--- a/packages/playwright-core/package.json
+++ b/packages/playwright-core/package.json
@@ -7,9 +7,6 @@
"engines": {
"node": ">=12"
},
- "scripts": {
- "prepare": "babel --config-file ../../babel.config.json -s --extensions \".ts\" --out-dir lib/utils/ src/utils"
- },
"author": {
"name": "Microsoft Corporation"
},
diff --git a/packages/playwright-firefox/install.js b/packages/playwright-firefox/install.js
index a59fe86db0..007009ac2f 100644
--- a/packages/playwright-firefox/install.js
+++ b/packages/playwright-firefox/install.js
@@ -14,6 +14,13 @@
* limitations under the License.
*/
-const { installBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');
+let install;
-installBrowsersForNpmInstall(['firefox']);
+try {
+ install = require('playwright-core/lib/utils/registry').installBrowsersForNpmInstall;
+} catch (e) {
+ // Dev build, don't install browsers by default.
+}
+
+if (install)
+ install(['firefox']);
diff --git a/packages/playwright-webkit/install.js b/packages/playwright-webkit/install.js
index 5340ee1776..e1bc2d41b0 100644
--- a/packages/playwright-webkit/install.js
+++ b/packages/playwright-webkit/install.js
@@ -14,6 +14,13 @@
* limitations under the License.
*/
-const { installBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');
+let install;
-installBrowsersForNpmInstall(['webkit']);
+try {
+ install = require('playwright-core/lib/utils/registry').installBrowsersForNpmInstall;
+} catch (e) {
+ // Dev build, don't install browsers by default.
+}
+
+if (install)
+ install(['webkit']);
diff --git a/packages/playwright/install.js b/packages/playwright/install.js
index eb7b13a93d..6439e553ad 100644
--- a/packages/playwright/install.js
+++ b/packages/playwright/install.js
@@ -14,6 +14,13 @@
* limitations under the License.
*/
-const { installDefaultBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');
+let install;
-installDefaultBrowsersForNpmInstall();
+try {
+ install = require('playwright-core/lib/utils/registry').installDefaultBrowsersForNpmInstall;
+} catch (e) {
+ // Dev build, don't install browsers by default.
+}
+
+if (install)
+ install();
diff --git a/utils/build/build.js b/utils/build/build.js
index 4737907a43..78d770d913 100644
--- a/utils/build/build.js
+++ b/utils/build/build.js
@@ -153,6 +153,14 @@ function copyFile(file, from, to) {
fs.copyFileSync(file, destination);
}
+// Update test runner.
+steps.push({
+ command: 'npm',
+ args: ['ci', '--save=false', '--fund=false', '--audit=false'],
+ shell: true,
+ cwd: path.join(__dirname, '..', '..', 'tests', 'playwright-test', 'stable-test-runner'),
+});
+
// Build injected scripts.
const webPackFiles = [
'packages/playwright-core/src/server/injected/webpack.config.js',