chore: removes dependency on Firefox Json endpoint (#10668)
This commit is contained in:
parent
6bca1db956
commit
c476058a16
@ -19,7 +19,10 @@ import fs from 'fs';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
import sinon from 'sinon';
|
||||||
|
|
||||||
import {CLI} from '../../../lib/cjs/CLI.js';
|
import {CLI} from '../../../lib/cjs/CLI.js';
|
||||||
|
import * as httpUtil from '../../../lib/cjs/httpUtil.js';
|
||||||
import {
|
import {
|
||||||
createMockedReadlineInterface,
|
createMockedReadlineInterface,
|
||||||
getServerUrl,
|
getServerUrl,
|
||||||
@ -46,6 +49,8 @@ describe('Firefox CLI', function () {
|
|||||||
`--path=${tmpDir}`,
|
`--path=${tmpDir}`,
|
||||||
`--base-url=${getServerUrl()}`,
|
`--base-url=${getServerUrl()}`,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
sinon.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should download Firefox binaries', async () => {
|
it('should download Firefox binaries', async () => {
|
||||||
@ -66,6 +71,9 @@ describe('Firefox CLI', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should download latest Firefox binaries', async () => {
|
it('should download latest Firefox binaries', async () => {
|
||||||
|
sinon
|
||||||
|
.stub(httpUtil, 'getJSON')
|
||||||
|
.returns(Promise.resolve({FIREFOX_NIGHTLY: testFirefoxBuildId}));
|
||||||
await new CLI(tmpDir).run([
|
await new CLI(tmpDir).run([
|
||||||
'npx',
|
'npx',
|
||||||
'@puppeteer/browsers',
|
'@puppeteer/browsers',
|
||||||
|
@ -19,12 +19,13 @@
|
|||||||
* mirrors the structure of the download server.
|
* mirrors the structure of the download server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {BrowserPlatform, install} from '@puppeteer/browsers';
|
import {existsSync, mkdirSync, copyFileSync, rmSync} from 'fs';
|
||||||
import path from 'path';
|
import {normalize, join, dirname} from 'path';
|
||||||
import fs from 'fs';
|
|
||||||
|
import {BrowserPlatform, install} from '@puppeteer/browsers';
|
||||||
|
|
||||||
import * as versions from '../test/build/versions.js';
|
|
||||||
import {downloadPaths} from '../lib/esm/browser-data/browser-data.js';
|
import {downloadPaths} from '../lib/esm/browser-data/browser-data.js';
|
||||||
|
import * as versions from '../test/build/versions.js';
|
||||||
|
|
||||||
function getBrowser(str) {
|
function getBrowser(str) {
|
||||||
const regex = /test(.+)BuildId/;
|
const regex = /test(.+)BuildId/;
|
||||||
@ -37,7 +38,7 @@ function getBrowser(str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cacheDir = path.normalize(path.join('.', 'test', 'cache'));
|
const cacheDir = normalize(join('.', 'test', 'cache'));
|
||||||
|
|
||||||
for (const version of Object.keys(versions)) {
|
for (const version of Object.keys(versions)) {
|
||||||
const browser = getBrowser(version);
|
const browser = getBrowser(version);
|
||||||
@ -49,13 +50,13 @@ for (const version of Object.keys(versions)) {
|
|||||||
const buildId = versions[version];
|
const buildId = versions[version];
|
||||||
|
|
||||||
for (const platform of Object.values(BrowserPlatform)) {
|
for (const platform of Object.values(BrowserPlatform)) {
|
||||||
const targetPath = path.join(
|
const targetPath = join(
|
||||||
cacheDir,
|
cacheDir,
|
||||||
'server',
|
'server',
|
||||||
...downloadPaths[browser](platform, buildId)
|
...downloadPaths[browser](platform, buildId)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fs.existsSync(targetPath)) {
|
if (existsSync(targetPath)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,18 +64,18 @@ for (const version of Object.keys(versions)) {
|
|||||||
browser,
|
browser,
|
||||||
buildId,
|
buildId,
|
||||||
platform,
|
platform,
|
||||||
cacheDir: path.join(cacheDir, 'tmp'),
|
cacheDir: join(cacheDir, 'tmp'),
|
||||||
unpack: false,
|
unpack: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.mkdirSync(path.dirname(targetPath), {
|
mkdirSync(dirname(targetPath), {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
});
|
});
|
||||||
fs.copyFileSync(archivePath, targetPath);
|
copyFileSync(archivePath, targetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.rmSync(path.join(cacheDir, 'tmp'), {
|
rmSync(join(cacheDir, 'tmp'), {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
force: true,
|
force: true,
|
||||||
maxRetries: 10,
|
maxRetries: 10,
|
||||||
|
Loading…
Reference in New Issue
Block a user