Skip to content

Commit

Permalink
devops: drop playwright-electron dependency on playwright-core (#2634)
Browse files Browse the repository at this point in the history
Drive-by: bump playwright-electron version to 0.4.0; i'll publish it
after this PR lands.
  • Loading branch information
aslushnikov committed Jun 19, 2020
1 parent 636e274 commit 2511cb4
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 40 deletions.
16 changes: 15 additions & 1 deletion packages/README.md
Expand Up @@ -2,7 +2,7 @@

## Overview

- Playwright ships multiple packages to NPM. All packges that are published to NPM are listed as folders under [`//packages/`](../packages).
- 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).
Expand Down Expand Up @@ -45,3 +45,17 @@ To test packages, use [`//packages/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.


# Special handling for `playwright-electron`

- `playwright-electron` version is pre-1.0.0 and thus managed separately. It's specified inside the [`//packages/build_package.js`]('./build_package.js') file.
- `playwright-electron` is published manually.

To publish a new version of `playwright-electron`:

1. Bump `playwright-electron` version inside [`//packages/build_package.js`]('./build_package.js')
2. Submit PR with the updated version
3. Build package with `./build_package.js playwright-electron ./playwright-electron.tgz`
4. Publish package with `npm publish playwright-electron.tgz`

46 changes: 26 additions & 20 deletions packages/build_package.js
Expand Up @@ -27,34 +27,40 @@ 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 PLAYWRIGHT_CORE_FILES = ['lib', 'types', 'NOTICE', 'LICENSE', '.npmignore'];

const PACKAGES = {
'playwright': {
description: 'A high-level API to automate web browsers',
whitelistedBrowsers: ['chromium', 'firefox', 'webkit'],
browsers: ['chromium', 'firefox', 'webkit'],
// We copy README.md additionally for Playwright so that it looks nice on NPM.
files: [...PACKAGE_FILES, 'README.md'],
files: [...PLAYWRIGHT_CORE_FILES, 'README.md'],
},
'playwright-core': {
description: 'A high-level API to automate web browsers',
whitelistedBrowsers: [],
files: PACKAGE_FILES,
browsers: [],
files: PLAYWRIGHT_CORE_FILES,
},
'playwright-webkit': {
description: 'A high-level API to automate WebKit',
whitelistedBrowsers: ['webkit'],
files: PACKAGE_FILES,
browsers: ['webkit'],
files: PLAYWRIGHT_CORE_FILES,
},
'playwright-firefox': {
description: 'A high-level API to automate Firefox',
whitelistedBrowsers: ['firefox'],
files: PACKAGE_FILES,
browsers: ['firefox'],
files: PLAYWRIGHT_CORE_FILES,
},
'playwright-chromium': {
description: 'A high-level API to automate Chromium',
whitelistedBrowsers: ['chromium'],
files: PACKAGE_FILES,
browsers: ['chromium'],
files: PLAYWRIGHT_CORE_FILES,
},
'playwright-electron': {
version: '0.4.0', // Manually manage playwright-electron version.
description: 'A high-level API to automate Electron',
browsers: [],
files: PLAYWRIGHT_CORE_FILES,
},
};

Expand Down Expand Up @@ -108,26 +114,26 @@ if (!package) {
await copyToPackage(file);

// 4. Generate package.json
const packageJSON = require(path.join(ROOT_PATH, 'package.json'));
const pwInternalJSON = require(path.join(ROOT_PATH, 'package.json'));
await writeToPackage('package.json', JSON.stringify({
name: packageName,
version: packageJSON.version,
version: package.version || pwInternalJSON.version,
description: package.description,
repository: packageJSON.repository,
engines: packageJSON.engines,
homepage: packageJSON.homepage,
repository: pwInternalJSON.repository,
engines: pwInternalJSON.engines,
homepage: pwInternalJSON.homepage,
main: 'index.js',
scripts: {
install: 'node install.js',
},
author: packageJSON.author,
license: packageJSON.license,
dependencies: packageJSON.dependencies
author: pwInternalJSON.author,
license: pwInternalJSON.license,
dependencies: pwInternalJSON.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));
browsersJSON.browsers = browsersJSON.browsers.filter(browser => package.browsers.includes(browser.name));
await writeToPackage('browsers.json', JSON.stringify(browsersJSON, null, 2));

// 6. Run npm pack
Expand Down
3 changes: 0 additions & 3 deletions packages/playwright-electron/browsers.json

This file was deleted.

17 changes: 17 additions & 0 deletions packages/playwright-electron/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-electron does not install browsers by design. */
16 changes: 0 additions & 16 deletions packages/playwright-electron/package.json

This file was deleted.

0 comments on commit 2511cb4

Please sign in to comment.