Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: move create-playwright build to build.js infra (#9687)
Max Schmitt94d1fcf83501
diff --git a/.github/workflows/package_create_playwright.yml b/.github/workflows/package_create_playwright.ymlindex bbd18525f9..ea9b8e649d 100644--- a/.github/workflows/package_create_playwright.yml+++ b/.github/workflows/package_create_playwright.yml@@ -11,9 +11,6 @@ on:jobs:build:runs-on: ubuntu-latest- defaults:- run:- working-directory: packages/create-playwright/steps:- uses: actions/checkout@v2- name: Use Node.js@@ -23,6 +20,6 @@ jobs: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+ working-directory: packages/create-playwright/diff --git a/package-lock.json b/package-lock.jsonindex 95295a87a3..d039d58bfb 100644--- a/package-lock.json+++ b/package-lock.json@@ -39,6 +39,7 @@"@types/yazl": "^2.4.2","@typescript-eslint/eslint-plugin": "^4.31.2","@typescript-eslint/parser": "^4.31.2",+ "@vercel/ncc": "^0.31.1","@zip.js/zip.js": "^2.3.17","ansi-to-html": "^0.7.1","babel-loader": "^8.2.2",@@ -50,6 +51,7 @@"cross-env": "^7.0.2","css-loader": "^6.4.0","electron": "^12.2.1",+ "enquirer": "^2.3.6","eslint": "^7.31.0","eslint-plugin-notice": "^0.9.10","eslint-plugin-react-hooks": "^4.2.0",@@ -1653,9 +1655,9 @@}},"node_modules/@vercel/ncc": {- "version": "0.30.0",- "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.30.0.tgz",- "integrity": "sha512-16ePj2GkwjomvE0HLL5ny+d+sudOwvZNYW8vjpMh3cyWdFxoMI8KSQiolVxeHBULbU1C5mVxLK5nL9NtnnpIew==",+ "version": "0.31.1",+ "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.31.1.tgz",+ "integrity": "sha512-g0FAxwdViI6UzsiVz5HssIHqjcPa1EHL6h+2dcJD893SoCJaGdqqgUF09xnMW6goWnnhbLvgiKlgJWrJa+7qYA==","dev": true,"bin": {"ncc": "dist/ncc/cli.js"@@ -9307,6 +9309,15 @@"integrity": "sha512-ho3Ruq+fFnBrZhUYI46n/bV2GjwzSkwuT4dTf0GkuNFmnb8nq4ny2z9JEVemFi6bdEJanHLlYfy9c6FN9B9McQ==","dev": true},+ "packages/create-playwright/node_modules/@vercel/ncc": {+ "version": "0.30.0",+ "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.30.0.tgz",+ "integrity": "sha512-16ePj2GkwjomvE0HLL5ny+d+sudOwvZNYW8vjpMh3cyWdFxoMI8KSQiolVxeHBULbU1C5mVxLK5nL9NtnnpIew==",+ "dev": true,+ "bin": {+ "ncc": "dist/ncc/cli.js"+ }+ },"packages/playwright": {"version": "1.17.0-next","hasInstallScript": true,@@ -10705,9 +10716,9 @@}},"@vercel/ncc": {- "version": "0.30.0",- "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.30.0.tgz",- "integrity": "sha512-16ePj2GkwjomvE0HLL5ny+d+sudOwvZNYW8vjpMh3cyWdFxoMI8KSQiolVxeHBULbU1C5mVxLK5nL9NtnnpIew==",+ "version": "0.31.1",+ "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.31.1.tgz",+ "integrity": "sha512-g0FAxwdViI6UzsiVz5HssIHqjcPa1EHL6h+2dcJD893SoCJaGdqqgUF09xnMW6goWnnhbLvgiKlgJWrJa+7qYA==","dev": true},"@webassemblyjs/ast": {@@ -11816,6 +11827,12 @@"resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.3.tgz","integrity": "sha512-ho3Ruq+fFnBrZhUYI46n/bV2GjwzSkwuT4dTf0GkuNFmnb8nq4ny2z9JEVemFi6bdEJanHLlYfy9c6FN9B9McQ==","dev": true+ },+ "@vercel/ncc": {+ "version": "0.30.0",+ "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.30.0.tgz",+ "integrity": "sha512-16ePj2GkwjomvE0HLL5ny+d+sudOwvZNYW8vjpMh3cyWdFxoMI8KSQiolVxeHBULbU1C5mVxLK5nL9NtnnpIew==",+ "dev": true}}},diff --git a/package.json b/package.jsonindex 0caee3a5fd..f20329d9c2 100644--- a/package.json+++ b/package.json@@ -68,6 +68,7 @@"@types/yazl": "^2.4.2","@typescript-eslint/eslint-plugin": "^4.31.2","@typescript-eslint/parser": "^4.31.2",+ "@vercel/ncc": "^0.31.1","@zip.js/zip.js": "^2.3.17","ansi-to-html": "^0.7.1","babel-loader": "^8.2.2",@@ -79,6 +80,7 @@"cross-env": "^7.0.2","css-loader": "^6.4.0","electron": "^12.2.1",+ "enquirer": "^2.3.6","eslint": "^7.31.0","eslint-plugin-notice": "^0.9.10","eslint-plugin-react-hooks": "^4.2.0",diff --git a/packages/create-playwright/package-lock.json b/packages/create-playwright/package-lock.jsondeleted file mode 100644index 524280d74f..0000000000--- a/packages/create-playwright/package-lock.json+++ /dev/null@@ -1,183 +0,0 @@-{- "name": "create-playwright",- "version": "0.1.7",- "lockfileVersion": 2,- "requires": true,- "packages": {- "": {- "version": "0.1.7",- "license": "MIT",- "bin": {- "create-playwright": "index.js"- },- "devDependencies": {- "@playwright/test": "file:../playwright-test",- "@types/node": "^16.9.0",- "@vercel/ncc": "^0.30.0",- "enquirer": "^2.3.6",- "typescript": "^4.4.2"- },- "engines": {- "node": ">=12"- }- },- "../playwright-test": {- "name": "@playwright/test",- "version": "1.17.0-next",- "dev": true,- "license": "Apache-2.0",- "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",- "expect": "^27.2.5",- "jest-matcher-utils": "^27.2.5",- "minimatch": "^3.0.3",- "ms": "^2.1.2",- "open": "^8.3.0",- "pirates": "^4.0.1",- "pixelmatch": "^5.2.1",- "playwright-core": "=1.17.0-next",- "source-map-support": "^0.4.18"- },- "engines": {- "node": ">=12"- }- },- "node_modules/@playwright/test": {- "resolved": "../playwright-test",- "link": true- },- "node_modules/@types/node": {- "version": "16.9.0",- "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.0.tgz",- "integrity": "sha512-nmP+VR4oT0pJUPFbKE4SXj3Yb4Q/kz3M9dSAO1GGMebRKWHQxLfDNmU/yh3xxCJha3N60nQ/JwXWwOE/ZSEVag==",- "dev": true- },- "node_modules/@vercel/ncc": {- "version": "0.30.0",- "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.30.0.tgz",- "integrity": "sha512-16ePj2GkwjomvE0HLL5ny+d+sudOwvZNYW8vjpMh3cyWdFxoMI8KSQiolVxeHBULbU1C5mVxLK5nL9NtnnpIew==",- "dev": true,- "bin": {- "ncc": "dist/ncc/cli.js"- }- },- "node_modules/ansi-colors": {- "version": "4.1.1",- "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",- "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",- "dev": true,- "engines": {- "node": ">=6"- }- },- "node_modules/enquirer": {- "version": "2.3.6",- "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",- "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==",- "dev": true,- "dependencies": {- "ansi-colors": "^4.1.1"- },- "engines": {- "node": ">=8.6"- }- },- "node_modules/typescript": {- "version": "4.4.2",- "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz",- "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==",- "dev": true,- "bin": {- "tsc": "bin/tsc",- "tsserver": "bin/tsserver"- },- "engines": {- "node": ">=4.2.0"- }- }- },- "dependencies": {- "@playwright/test": {- "version": "file:../playwright-test",- "requires": {- "@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",- "expect": "^27.2.5",- "jest-matcher-utils": "^27.2.5",- "minimatch": "^3.0.3",- "ms": "^2.1.2",- "open": "^8.3.0",- "pirates": "^4.0.1",- "pixelmatch": "^5.2.1",- "playwright-core": "=1.17.0-next",- "source-map-support": "^0.4.18"- }- },- "@types/node": {- "version": "16.9.0",- "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.0.tgz",- "integrity": "sha512-nmP+VR4oT0pJUPFbKE4SXj3Yb4Q/kz3M9dSAO1GGMebRKWHQxLfDNmU/yh3xxCJha3N60nQ/JwXWwOE/ZSEVag==",- "dev": true- },- "@vercel/ncc": {- "version": "0.30.0",- "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.30.0.tgz",- "integrity": "sha512-16ePj2GkwjomvE0HLL5ny+d+sudOwvZNYW8vjpMh3cyWdFxoMI8KSQiolVxeHBULbU1C5mVxLK5nL9NtnnpIew==",- "dev": true- },- "ansi-colors": {- "version": "4.1.1",- "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",- "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",- "dev": true- },- "enquirer": {- "version": "2.3.6",- "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",- "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==",- "dev": true,- "requires": {- "ansi-colors": "^4.1.1"- }- },- "typescript": {- "version": "4.4.2",- "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz",- "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==",- "dev": true- }- }-}diff --git a/packages/create-playwright/package.json b/packages/create-playwright/package.jsonindex ebb1e20084..0015bda8b7 100644--- a/packages/create-playwright/package.json+++ b/packages/create-playwright/package.json@@ -14,15 +14,6 @@},"license": "MIT","scripts": {- "prepublish": "npm run build",- "watch": "cd src && ncc build cli.ts --watch --out ../lib && cd ..",- "build": "cd src && ncc build cli.ts --minify --out ../lib && cd ..","test": "npx playwright test"- },- "devDependencies": {- "@types/node": "^16.9.0",- "@vercel/ncc": "^0.30.0",- "enquirer": "^2.3.6",- "typescript": "^4.4.2"}}diff --git a/utils/build/build.js b/utils/build/build.jsindex a9c5eb30cf..221a392775 100644--- a/utils/build/build.js+++ b/utils/build/build.js@@ -28,20 +28,43 @@ const { packages } = require('../list_packages');* args: string[],* shell: boolean,* env?: NodeJS.ProcessEnv,+ * cwd?: string,* }} Step*//**- * @type {Step[]}+ * @typedef {{+ * files: string,+ * from: string,+ * to: string,+ * ignored?: string[],+ * }} CopyFile+ */++/**+ * @typedef {{+ * committed: boolean,+ * inputs: string[],+ * mustExist?: string[],+ * script: string,+ * }} OnChange*/++/** @type {Step[]} */const steps = [];+/** @type {OnChange[]} */const onChanges = [];+/** @type {CopyFile[]} */const copyFiles = [];const watchMode = process.argv.slice(2).includes('--watch');const lintMode = process.argv.slice(2).includes('--lint');const ROOT = path.join(__dirname, '..', '..');+/**+ * @param {string} relative+ * @returns {string}+ */function filePath(relative) {return path.join(ROOT, ...relative.split('/'));}@@ -66,13 +89,17 @@ async function runWatch() {copyFile(file, from, to);});}+ /** @type{import('child_process').ChildProcess[]} */const spawns = [];for (const step of steps)spawns.push(child_process.spawn(step.command, step.args, {- stdio: 'inherit', shell: step.shell, env: {+ stdio: 'inherit',+ shell: step.shell,+ env: {...process.env,...step.env,- }+ },+ cwd: step.cwd,}));process.on('exit', () => spawns.forEach(s => s.kill()));for (const onChange of onChanges)@@ -85,10 +112,13 @@ async function runBuild() {*/function runStep(step) {const out = child_process.spawnSync(step.command, step.args, {- stdio: 'inherit', shell: step.shell, env: {+ stdio: 'inherit',+ shell: step.shell,+ env: {...process.env,...step.env- }+ },+ cwd: step.cwd,});if (out.status)process.exit(out.status);@@ -112,6 +142,11 @@ async function runBuild() {}}+/**+ * @param {string} file+ * @param {string} from+ * @param {string} to+ */function copyFile(file, from, to) {const destination = path.resolve(filePath(to), path.relative(filePath(from), file));fs.mkdirSync(path.dirname(destination), { recursive: true });@@ -141,6 +176,8 @@ for (const file of webPackFiles) {for (const packageDir of packages) {if (!fs.existsSync(path.join(packageDir, 'src')))continue;+ if (path.basename(packageDir) === 'create-playwright')+ continue;steps.push({command: 'npx',args: [@@ -148,7 +185,7 @@ for (const packageDir of packages) {...(watchMode ? ['-w', '--source-maps'] : []),'--extensions', '.ts','--out-dir', path.join(packageDir, 'lib'),- '--ignore', 'packages/playwright-core/src/server/injected/**/*',+ '--ignore', '"packages/playwright-core/src/server/injected/**/*","packages/create-playwright/**/*"',path.join(packageDir, 'src')],shell: true,});@@ -225,4 +262,12 @@ if (lintMode) {});}+// create-playwright package+steps.push({+ command: 'npx',+ args: ['ncc', 'build', 'cli.ts', (watchMode ? '--watch' : '--minify'), '--out', '../lib'],+ shell: true,+ cwd: 'packages/create-playwright/src'+});+watchMode ? runWatch() : runBuild();