Browse Source

chore: do not bundle api.json and protocol.yml (#6841)

These are only needed for the driver, so bundle them
in the driver explicitly.
pull/6860/head
Dmitry Gozman 2 weeks ago
committed by GitHub
parent
commit
33c2f6c31e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 3
      packages/build_package.js
  3. 3
      packages/common/.npmignore
  4. 6
      src/cli/driver.ts
  5. 6
      utils/build/build-playwright-driver.sh
  6. 9
      utils/build/build.js
  7. 2
      utils/doclint/generateApiJson.js

1
.gitignore

@ -14,5 +14,4 @@ drivers/
.android-sdk/
.gradle/
nohup.out
api.json
.trace

3
packages/build_package.js

@ -113,9 +113,6 @@ if (!args.some(arg => arg === '--no-cleanup')) {
for (const file of package.files)
await copyToPackage(path.join(ROOT_PATH, file), path.join(packagePath, file));
await copyToPackage(path.join(ROOT_PATH, 'api.json'), path.join(packagePath, 'api.json'));
await copyToPackage(path.join(ROOT_PATH, 'src/protocol/protocol.yml'), path.join(packagePath, 'protocol.yml'));
// 4. Generate package.json
const pwInternalJSON = require(path.join(ROOT_PATH, 'package.json'));
await writeToPackage('package.json', JSON.stringify({

3
packages/common/.npmignore

@ -32,9 +32,6 @@ lib/**/injected/
!README.md
!LICENSE
!NOTICE
# Include protocol and api docs, so that dependent packages can consume them.
!api.json
!protocol.yml
# Include browser descriptors.
!browsers.json
# Include commit info

6
src/cli/driver.ts

@ -17,7 +17,6 @@
/* eslint-disable no-console */
import fs from 'fs';
import path from 'path';
import * as playwright from '../..';
import { BrowserType } from '../client/browserType';
import { LaunchServerOptions } from '../client/types';
@ -31,13 +30,10 @@ import { gracefullyCloseAll } from '../server/processLauncher';
import { BrowserName } from '../utils/registry';
export function printApiJson() {
// Note: this file is generated by build-playwright-driver.sh
console.log(JSON.stringify(require('../../api.json')));
}
export function printProtocol() {
console.log(fs.readFileSync(path.join(__dirname, '..', '..', 'protocol.yml'), 'utf8'));
}
export function runDriver() {
const dispatcherConnection = new DispatcherConnection();
const transport = new Transport(process.stdout, process.stdin);

6
utils/build/build-playwright-driver.sh

@ -13,6 +13,10 @@ mkdir -p ./output
echo "Building playwright package"
../../packages/build_package.js playwright ./output/playwright.tgz
echo "Building api.json and protocol.yml"
node ../../utils/doclint/generateApiJson.js > ./output/api.json
cp ../../src/protocol/protocol.yml ./output/
function build {
NODE_DIR=$1
SUFFIX=$2
@ -45,6 +49,8 @@ function build {
fi
cp ./output/${NODE_DIR}/LICENSE ./output/playwright-${SUFFIX}/
cp ./output/api.json ./output/playwright-${SUFFIX}/package/
cp ./output/protocol.yml ./output/playwright-${SUFFIX}/package/
cd ./output/playwright-${SUFFIX}/package
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 node "../../${NODE_DIR}/${NPM_PATH}" install --production
rm package-lock.json

9
utils/build/build.js

@ -91,15 +91,6 @@ steps.push({
shell: true,
});
// Generate api.json.
onChanges.push({
committed: false,
inputs: [
'docs/src/api/',
],
script: 'utils/doclint/generateApiJson.js',
});
// Generate channels.
onChanges.push({
committed: false,

2
utils/doclint/generateApiJson.js

@ -35,7 +35,7 @@ const PROJECT_DIR = path.join(__dirname, '..', '..');
});
documentation.generateSourceCodeComments();
const result = serialize(documentation);
fs.writeFileSync(path.join(PROJECT_DIR, 'api.json'), JSON.stringify(result));
console.log(JSON.stringify(result));
}
/**

Loading…
Cancel
Save