fix: use puppeteer node for installation script (#9489)

Fixed: https://github.com/puppeteer/puppeteer/issues/9470
This commit is contained in:
jrandolf 2023-01-11 16:15:53 +01:00 committed by GitHub
parent 29b948197d
commit 9bf90d9f4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 17 deletions

View File

@ -8,8 +8,10 @@ sidebar_label: createBrowserFetcher
```typescript
createBrowserFetcher: (
options: Partial<
import('puppeteer-core/internal/puppeteer-core.js').BrowserFetcherOptions
>
options?:
| Partial<
import('puppeteer-core/internal/puppeteer-core.js').BrowserFetcherOptions
>
| undefined
) => import('puppeteer-core/internal/puppeteer-core.js').BrowserFetcher;
```

View File

@ -8,15 +8,17 @@ sidebar_label: PuppeteerNode.createBrowserFetcher
```typescript
class PuppeteerNode {
createBrowserFetcher(options: Partial<BrowserFetcherOptions>): BrowserFetcher;
createBrowserFetcher(
options?: Partial<BrowserFetcherOptions>
): BrowserFetcher;
}
```
## Parameters
| Parameter | Type | Description |
| --------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| options | Partial&lt;[BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md)&gt; | Set of configurable options to specify the settings of the BrowserFetcher. |
| Parameter | Type | Description |
| --------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| options | Partial&lt;[BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md)&gt; | <i>(Optional)</i> Set of configurable options to specify the settings of the BrowserFetcher. |
**Returns:**

View File

@ -289,7 +289,7 @@ export class PuppeteerNode extends Puppeteer {
* @returns A new BrowserFetcher instance.
*/
createBrowserFetcher(
options: Partial<BrowserFetcherOptions>
options: Partial<BrowserFetcherOptions> = {}
): BrowserFetcher {
const downloadPath = this.defaultDownloadPath;
if (downloadPath) {
@ -304,6 +304,9 @@ export class PuppeteerNode extends Puppeteer {
if (this.configuration.downloadHost) {
options.host = this.configuration.downloadHost;
}
if (this.configuration.defaultProduct) {
options.product = this.configuration.defaultProduct;
}
return new BrowserFetcher(options as BrowserFetcherOptions);
}
}

View File

@ -16,10 +16,9 @@
import https, {RequestOptions} from 'https';
import createHttpsProxyAgent, {HttpsProxyAgentOptions} from 'https-proxy-agent';
import {join} from 'path';
import ProgressBar from 'progress';
import {getProxyForUrl} from 'proxy-from-env';
import {BrowserFetcher} from 'puppeteer-core';
import {PuppeteerNode} from 'puppeteer-core/internal/node/PuppeteerNode.js';
import {PUPPETEER_REVISIONS} from 'puppeteer-core/internal/revisions.js';
import URL from 'url';
import {getConfiguration} from '../getConfiguration.js';
@ -42,14 +41,10 @@ export async function downloadBrowser(): Promise<void> {
return;
}
const puppeteer = new PuppeteerNode({configuration, isPuppeteerCore: false});
const product = configuration.defaultProduct!;
const browserFetcher = new BrowserFetcher({
product,
host: configuration.downloadHost,
path:
configuration.downloadPath ??
join(configuration.cacheDirectory!, product),
});
const browserFetcher = puppeteer.createBrowserFetcher();
let revision = configuration.browserRevision;