@checkly/playwright-core 1.41.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +3 -0
- package/ThirdPartyNotices.txt +1513 -0
- package/bin/PrintDeps.exe +0 -0
- package/bin/README.md +2 -0
- package/bin/install_media_pack.ps1 +5 -0
- package/bin/reinstall_chrome_beta_linux.sh +40 -0
- package/bin/reinstall_chrome_beta_mac.sh +13 -0
- package/bin/reinstall_chrome_beta_win.ps1 +23 -0
- package/bin/reinstall_chrome_stable_linux.sh +40 -0
- package/bin/reinstall_chrome_stable_mac.sh +12 -0
- package/bin/reinstall_chrome_stable_win.ps1 +23 -0
- package/bin/reinstall_msedge_beta_linux.sh +40 -0
- package/bin/reinstall_msedge_beta_mac.sh +11 -0
- package/bin/reinstall_msedge_beta_win.ps1 +22 -0
- package/bin/reinstall_msedge_dev_linux.sh +40 -0
- package/bin/reinstall_msedge_dev_mac.sh +11 -0
- package/bin/reinstall_msedge_dev_win.ps1 +22 -0
- package/bin/reinstall_msedge_stable_linux.sh +40 -0
- package/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/bin/reinstall_msedge_stable_win.ps1 +23 -0
- package/browsers.json +64 -0
- package/cli.js +17 -0
- package/index.d.ts +17 -0
- package/index.js +33 -0
- package/index.mjs +28 -0
- package/lib/androidServerImpl.js +69 -0
- package/lib/browserServerImpl.js +92 -0
- package/lib/cli/driver.js +97 -0
- package/lib/cli/program.js +582 -0
- package/lib/cli/programWithTestStub.js +67 -0
- package/lib/client/accessibility.js +50 -0
- package/lib/client/android.js +473 -0
- package/lib/client/api.js +272 -0
- package/lib/client/artifact.js +79 -0
- package/lib/client/browser.js +145 -0
- package/lib/client/browserContext.js +509 -0
- package/lib/client/browserType.js +233 -0
- package/lib/client/cdpSession.js +53 -0
- package/lib/client/channelOwner.js +229 -0
- package/lib/client/clientHelper.js +57 -0
- package/lib/client/clientInstrumentation.js +40 -0
- package/lib/client/connection.js +327 -0
- package/lib/client/consoleMessage.js +55 -0
- package/lib/client/coverage.js +41 -0
- package/lib/client/dialog.js +57 -0
- package/lib/client/download.js +62 -0
- package/lib/client/electron.js +130 -0
- package/lib/client/elementHandle.js +291 -0
- package/lib/client/errors.js +77 -0
- package/lib/client/events.js +93 -0
- package/lib/client/fetch.js +343 -0
- package/lib/client/fileChooser.js +45 -0
- package/lib/client/frame.js +506 -0
- package/lib/client/harRouter.js +93 -0
- package/lib/client/input.js +111 -0
- package/lib/client/jsHandle.js +123 -0
- package/lib/client/jsonPipe.js +35 -0
- package/lib/client/localUtils.js +35 -0
- package/lib/client/locator.js +432 -0
- package/lib/client/network.js +601 -0
- package/lib/client/page.js +707 -0
- package/lib/client/playwright.js +74 -0
- package/lib/client/selectors.js +67 -0
- package/lib/client/stream.js +54 -0
- package/lib/client/tracing.js +135 -0
- package/lib/client/types.js +24 -0
- package/lib/client/video.js +51 -0
- package/lib/client/waiter.js +158 -0
- package/lib/client/webError.js +37 -0
- package/lib/client/worker.js +71 -0
- package/lib/client/writableStream.js +54 -0
- package/lib/common/socksProxy.js +569 -0
- package/lib/common/timeoutSettings.js +73 -0
- package/lib/common/types.js +5 -0
- package/lib/generated/consoleApiSource.js +7 -0
- package/lib/generated/injectedScriptSource.js +7 -0
- package/lib/generated/recorderSource.js +7 -0
- package/lib/generated/utilityScriptSource.js +7 -0
- package/lib/image_tools/colorUtils.js +98 -0
- package/lib/image_tools/compare.js +108 -0
- package/lib/image_tools/imageChannel.js +70 -0
- package/lib/image_tools/stats.js +102 -0
- package/lib/inProcessFactory.js +54 -0
- package/lib/inprocess.js +20 -0
- package/lib/outofprocess.js +67 -0
- package/lib/protocol/debug.js +27 -0
- package/lib/protocol/serializers.js +172 -0
- package/lib/protocol/transport.js +82 -0
- package/lib/protocol/validator.js +2599 -0
- package/lib/protocol/validatorPrimitives.js +139 -0
- package/lib/remote/playwrightConnection.js +274 -0
- package/lib/remote/playwrightServer.js +110 -0
- package/lib/server/accessibility.js +62 -0
- package/lib/server/android/android.js +441 -0
- package/lib/server/android/backendAdb.js +172 -0
- package/lib/server/artifact.js +104 -0
- package/lib/server/browser.js +129 -0
- package/lib/server/browserContext.js +609 -0
- package/lib/server/browserType.js +300 -0
- package/lib/server/chromium/appIcon.png +0 -0
- package/lib/server/chromium/chromium.js +346 -0
- package/lib/server/chromium/chromiumSwitches.js +41 -0
- package/lib/server/chromium/crAccessibility.js +237 -0
- package/lib/server/chromium/crBrowser.js +521 -0
- package/lib/server/chromium/crConnection.js +228 -0
- package/lib/server/chromium/crCoverage.js +246 -0
- package/lib/server/chromium/crDevTools.js +104 -0
- package/lib/server/chromium/crDragDrop.js +144 -0
- package/lib/server/chromium/crExecutionContext.js +156 -0
- package/lib/server/chromium/crInput.js +171 -0
- package/lib/server/chromium/crNetworkManager.js +723 -0
- package/lib/server/chromium/crPage.js +1173 -0
- package/lib/server/chromium/crPdf.js +147 -0
- package/lib/server/chromium/crProtocolHelper.js +131 -0
- package/lib/server/chromium/crServiceWorker.js +115 -0
- package/lib/server/chromium/defaultFontFamilies.js +145 -0
- package/lib/server/chromium/videoRecorder.js +155 -0
- package/lib/server/console.js +59 -0
- package/lib/server/cookieStore.js +112 -0
- package/lib/server/debugController.js +236 -0
- package/lib/server/debugger.js +132 -0
- package/lib/server/deviceDescriptors.js +21 -0
- package/lib/server/deviceDescriptorsSource.json +1549 -0
- package/lib/server/dialog.js +70 -0
- package/lib/server/dispatchers/androidDispatcher.js +193 -0
- package/lib/server/dispatchers/artifactDispatcher.js +118 -0
- package/lib/server/dispatchers/browserContextDispatcher.js +306 -0
- package/lib/server/dispatchers/browserDispatcher.js +170 -0
- package/lib/server/dispatchers/browserTypeDispatcher.js +55 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +48 -0
- package/lib/server/dispatchers/debugControllerDispatcher.js +103 -0
- package/lib/server/dispatchers/dialogDispatcher.js +44 -0
- package/lib/server/dispatchers/dispatcher.js +400 -0
- package/lib/server/dispatchers/electronDispatcher.js +80 -0
- package/lib/server/dispatchers/elementHandlerDispatcher.js +228 -0
- package/lib/server/dispatchers/frameDispatcher.js +287 -0
- package/lib/server/dispatchers/jsHandleDispatcher.js +102 -0
- package/lib/server/dispatchers/jsonPipeDispatcher.js +61 -0
- package/lib/server/dispatchers/localUtilsDispatcher.js +399 -0
- package/lib/server/dispatchers/networkDispatchers.js +221 -0
- package/lib/server/dispatchers/pageDispatcher.js +363 -0
- package/lib/server/dispatchers/playwrightDispatcher.js +105 -0
- package/lib/server/dispatchers/selectorsDispatcher.js +36 -0
- package/lib/server/dispatchers/streamDispatcher.js +62 -0
- package/lib/server/dispatchers/tracingDispatcher.js +54 -0
- package/lib/server/dispatchers/writableStreamDispatcher.js +55 -0
- package/lib/server/dom.js +808 -0
- package/lib/server/download.js +53 -0
- package/lib/server/electron/electron.js +254 -0
- package/lib/server/electron/loader.js +57 -0
- package/lib/server/errors.js +68 -0
- package/lib/server/fetch.js +611 -0
- package/lib/server/fileChooser.js +42 -0
- package/lib/server/fileUploadUtils.js +71 -0
- package/lib/server/firefox/ffAccessibility.js +215 -0
- package/lib/server/firefox/ffBrowser.js +447 -0
- package/lib/server/firefox/ffConnection.js +168 -0
- package/lib/server/firefox/ffExecutionContext.js +138 -0
- package/lib/server/firefox/ffInput.js +150 -0
- package/lib/server/firefox/ffNetworkManager.js +231 -0
- package/lib/server/firefox/ffPage.js +558 -0
- package/lib/server/firefox/firefox.js +91 -0
- package/lib/server/formData.js +75 -0
- package/lib/server/frameSelectors.js +171 -0
- package/lib/server/frames.js +1597 -0
- package/lib/server/har/harRecorder.js +139 -0
- package/lib/server/har/harTracer.js +539 -0
- package/lib/server/helper.js +103 -0
- package/lib/server/index.js +96 -0
- package/lib/server/input.js +301 -0
- package/lib/server/instrumentation.js +74 -0
- package/lib/server/isomorphic/utilityScriptSerializers.js +212 -0
- package/lib/server/javascript.js +305 -0
- package/lib/server/launchApp.js +90 -0
- package/lib/server/macEditingCommands.js +139 -0
- package/lib/server/network.js +607 -0
- package/lib/server/page.js +793 -0
- package/lib/server/pipeTransport.js +85 -0
- package/lib/server/playwright.js +82 -0
- package/lib/server/progress.js +102 -0
- package/lib/server/protocolError.js +49 -0
- package/lib/server/recorder/codeGenerator.js +153 -0
- package/lib/server/recorder/csharp.js +310 -0
- package/lib/server/recorder/java.js +216 -0
- package/lib/server/recorder/javascript.js +229 -0
- package/lib/server/recorder/jsonl.js +47 -0
- package/lib/server/recorder/language.js +44 -0
- package/lib/server/recorder/python.js +275 -0
- package/lib/server/recorder/recorderActions.js +5 -0
- package/lib/server/recorder/recorderApp.js +181 -0
- package/lib/server/recorder/recorderUtils.js +48 -0
- package/lib/server/recorder/utils.js +45 -0
- package/lib/server/recorder.js +700 -0
- package/lib/server/registry/browserFetcher.js +168 -0
- package/lib/server/registry/dependencies.js +322 -0
- package/lib/server/registry/index.js +925 -0
- package/lib/server/registry/nativeDeps.js +383 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +138 -0
- package/lib/server/screenshotter.js +354 -0
- package/lib/server/selectors.js +73 -0
- package/lib/server/socksInterceptor.js +100 -0
- package/lib/server/trace/recorder/snapshotter.js +168 -0
- package/lib/server/trace/recorder/snapshotterInjected.js +493 -0
- package/lib/server/trace/recorder/tracing.js +552 -0
- package/lib/server/trace/test/inMemorySnapshotter.js +93 -0
- package/lib/server/trace/viewer/traceViewer.js +229 -0
- package/lib/server/transport.js +191 -0
- package/lib/server/types.js +24 -0
- package/lib/server/usKeyboardLayout.js +555 -0
- package/lib/server/webkit/webkit.js +87 -0
- package/lib/server/webkit/wkAccessibility.js +194 -0
- package/lib/server/webkit/wkBrowser.js +328 -0
- package/lib/server/webkit/wkConnection.js +173 -0
- package/lib/server/webkit/wkExecutionContext.js +146 -0
- package/lib/server/webkit/wkInput.js +169 -0
- package/lib/server/webkit/wkInterceptableRequest.js +158 -0
- package/lib/server/webkit/wkPage.js +1198 -0
- package/lib/server/webkit/wkProvisionalPage.js +59 -0
- package/lib/server/webkit/wkWorkers.js +104 -0
- package/lib/third_party/diff_match_patch.js +2222 -0
- package/lib/third_party/pixelmatch.js +255 -0
- package/lib/utils/ascii.js +31 -0
- package/lib/utils/comparators.js +171 -0
- package/lib/utils/crypto.js +33 -0
- package/lib/utils/debug.js +46 -0
- package/lib/utils/debugLogger.js +89 -0
- package/lib/utils/env.js +47 -0
- package/lib/utils/eventsHelper.js +38 -0
- package/lib/utils/fileUtils.js +66 -0
- package/lib/utils/glob.js +83 -0
- package/lib/utils/happy-eyeballs.js +154 -0
- package/lib/utils/headers.js +52 -0
- package/lib/utils/hostPlatform.js +124 -0
- package/lib/utils/httpServer.js +195 -0
- package/lib/utils/index.js +324 -0
- package/lib/utils/isomorphic/cssParser.js +250 -0
- package/lib/utils/isomorphic/cssTokenizer.js +979 -0
- package/lib/utils/isomorphic/locatorGenerators.js +651 -0
- package/lib/utils/isomorphic/locatorParser.js +179 -0
- package/lib/utils/isomorphic/locatorUtils.js +62 -0
- package/lib/utils/isomorphic/selectorParser.js +397 -0
- package/lib/utils/isomorphic/stringUtils.js +107 -0
- package/lib/utils/isomorphic/traceUtils.js +39 -0
- package/lib/utils/linuxUtils.js +78 -0
- package/lib/utils/manualPromise.js +109 -0
- package/lib/utils/mimeType.js +29 -0
- package/lib/utils/multimap.js +75 -0
- package/lib/utils/network.js +189 -0
- package/lib/utils/processLauncher.js +248 -0
- package/lib/utils/profiler.js +53 -0
- package/lib/utils/rtti.js +41 -0
- package/lib/utils/semaphore.js +51 -0
- package/lib/utils/spawnAsync.js +45 -0
- package/lib/utils/stackTrace.js +123 -0
- package/lib/utils/task.js +58 -0
- package/lib/utils/time.js +37 -0
- package/lib/utils/timeoutRunner.js +131 -0
- package/lib/utils/traceUtils.js +44 -0
- package/lib/utils/userAgent.js +105 -0
- package/lib/utils/wsServer.js +125 -0
- package/lib/utils/zipFile.js +75 -0
- package/lib/utils/zones.js +99 -0
- package/lib/utilsBundle.js +81 -0
- package/lib/utilsBundleImpl/index.js +51 -0
- package/lib/utilsBundleImpl/xdg-open +1066 -0
- package/lib/vite/htmlReport/index.html +66 -0
- package/lib/vite/recorder/assets/codeMirrorModule-Hs9-1ZG4.css +1 -0
- package/lib/vite/recorder/assets/codeMirrorModule-I9ks4y7D.js +24 -0
- package/lib/vite/recorder/assets/codicon-zGuYmc9o.ttf +0 -0
- package/lib/vite/recorder/assets/index-ljsTwXtJ.css +1 -0
- package/lib/vite/recorder/assets/index-yg8ypzl6.js +47 -0
- package/lib/vite/recorder/index.html +29 -0
- package/lib/vite/recorder/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-GluP1cQ1.js +24 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-fqJB1XDu.js +24 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-y3M3aAqy.js +24 -0
- package/lib/vite/traceViewer/assets/wsPort-Rvwd4WC-.js +69 -0
- package/lib/vite/traceViewer/assets/wsPort-dlD7vDkY.js +69 -0
- package/lib/vite/traceViewer/assets/wsPort-qOE2NWrO.js +69 -0
- package/lib/vite/traceViewer/assets/xtermModule-Yt6xwiJ_.js +9 -0
- package/lib/vite/traceViewer/codeMirrorModule.Hs9-1ZG4.css +1 -0
- package/lib/vite/traceViewer/codicon.zGuYmc9o.ttf +0 -0
- package/lib/vite/traceViewer/index.-g_5lMbJ.css +1 -0
- package/lib/vite/traceViewer/index.4X7zDysg.js +2 -0
- package/lib/vite/traceViewer/index.HkJgzlGy.js +2 -0
- package/lib/vite/traceViewer/index.html +26 -0
- package/lib/vite/traceViewer/index.kRjx5sAJ.js +2 -0
- package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/snapshot.html +21 -0
- package/lib/vite/traceViewer/sw.bundle.js +4 -0
- package/lib/vite/traceViewer/uiMode.1Wcp_Kto.js +10 -0
- package/lib/vite/traceViewer/uiMode.GTNzARcV.js +10 -0
- package/lib/vite/traceViewer/uiMode.html +17 -0
- package/lib/vite/traceViewer/uiMode.pWy0Re7G.css +1 -0
- package/lib/vite/traceViewer/uiMode.zV-7Lf9v.js +10 -0
- package/lib/vite/traceViewer/wsPort.kSgQKQ0y.css +1 -0
- package/lib/vite/traceViewer/xtermModule.0lwXJFHT.css +32 -0
- package/lib/zipBundle.js +25 -0
- package/lib/zipBundleImpl.js +5 -0
- package/package.json +43 -0
- package/types/protocol.d.ts +20304 -0
- package/types/structs.d.ts +45 -0
- package/types/types.d.ts +20626 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.downloadBrowserWithProgressBar = downloadBrowserWithProgressBar;
|
|
7
|
+
exports.logPolitely = logPolitely;
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
var _os = _interopRequireDefault(require("os"));
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _child_process = _interopRequireDefault(require("child_process"));
|
|
12
|
+
var _fileUtils = require("../../utils/fileUtils");
|
|
13
|
+
var _debugLogger = require("../../utils/debugLogger");
|
|
14
|
+
var _manualPromise = require("../../utils/manualPromise");
|
|
15
|
+
var _utilsBundle = require("../../utilsBundle");
|
|
16
|
+
var _ = require(".");
|
|
17
|
+
var _userAgent = require("../../utils/userAgent");
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
/**
|
|
20
|
+
* Copyright 2017 Google Inc. All rights reserved.
|
|
21
|
+
* Modifications copyright (c) Microsoft Corporation.
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
24
|
+
* you may not use this file except in compliance with the License.
|
|
25
|
+
* You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
async function downloadBrowserWithProgressBar(title, browserDirectory, executablePath, downloadURLs, downloadFileName, downloadConnectionTimeout) {
|
|
37
|
+
if (await (0, _fileUtils.existsAsync)((0, _.browserDirectoryToMarkerFilePath)(browserDirectory))) {
|
|
38
|
+
// Already downloaded.
|
|
39
|
+
_debugLogger.debugLogger.log('install', `${title} is already downloaded.`);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const zipPath = _path.default.join(_os.default.tmpdir(), downloadFileName);
|
|
43
|
+
try {
|
|
44
|
+
const retryCount = 3;
|
|
45
|
+
for (let attempt = 1; attempt <= retryCount; ++attempt) {
|
|
46
|
+
_debugLogger.debugLogger.log('install', `downloading ${title} - attempt #${attempt}`);
|
|
47
|
+
const url = downloadURLs[(attempt - 1) % downloadURLs.length];
|
|
48
|
+
logPolitely(`Downloading ${title}` + _utilsBundle.colors.dim(` from ${url}`));
|
|
49
|
+
const {
|
|
50
|
+
error
|
|
51
|
+
} = await downloadBrowserWithProgressBarOutOfProcess(title, browserDirectory, url, zipPath, executablePath, downloadConnectionTimeout);
|
|
52
|
+
if (!error) {
|
|
53
|
+
_debugLogger.debugLogger.log('install', `SUCCESS installing ${title}`);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
if (await (0, _fileUtils.existsAsync)(zipPath)) await _fs.default.promises.unlink(zipPath);
|
|
57
|
+
if (await (0, _fileUtils.existsAsync)(browserDirectory)) await _fs.default.promises.rmdir(browserDirectory, {
|
|
58
|
+
recursive: true
|
|
59
|
+
});
|
|
60
|
+
const errorMessage = (error === null || error === void 0 ? void 0 : error.message) || '';
|
|
61
|
+
_debugLogger.debugLogger.log('install', `attempt #${attempt} - ERROR: ${errorMessage}`);
|
|
62
|
+
if (attempt >= retryCount) throw error;
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
_debugLogger.debugLogger.log('install', `FAILED installation ${title} with error: ${e}`);
|
|
66
|
+
process.exitCode = 1;
|
|
67
|
+
throw e;
|
|
68
|
+
} finally {
|
|
69
|
+
if (await (0, _fileUtils.existsAsync)(zipPath)) await _fs.default.promises.unlink(zipPath);
|
|
70
|
+
}
|
|
71
|
+
logPolitely(`${title} downloaded to ${browserDirectory}`);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Node.js has a bug where the process can exit with 0 code even though there was an uncaught exception.
|
|
77
|
+
* Thats why we execute it in a separate process and check manually if the destination file exists.
|
|
78
|
+
* https://github.com/microsoft/playwright/issues/17394
|
|
79
|
+
*/
|
|
80
|
+
function downloadBrowserWithProgressBarOutOfProcess(title, browserDirectory, url, zipPath, executablePath, connectionTimeout) {
|
|
81
|
+
const cp = _child_process.default.fork(_path.default.join(__dirname, 'oopDownloadBrowserMain.js'));
|
|
82
|
+
const promise = new _manualPromise.ManualPromise();
|
|
83
|
+
const progress = getDownloadProgress();
|
|
84
|
+
cp.on('message', message => {
|
|
85
|
+
if ((message === null || message === void 0 ? void 0 : message.method) === 'log') _debugLogger.debugLogger.log('install', message.params.message);
|
|
86
|
+
if ((message === null || message === void 0 ? void 0 : message.method) === 'progress') progress(message.params.done, message.params.total);
|
|
87
|
+
});
|
|
88
|
+
cp.on('exit', code => {
|
|
89
|
+
if (code !== 0) {
|
|
90
|
+
promise.resolve({
|
|
91
|
+
error: new Error(`Download failure, code=${code}`)
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!_fs.default.existsSync((0, _.browserDirectoryToMarkerFilePath)(browserDirectory))) promise.resolve({
|
|
96
|
+
error: new Error(`Download failure, ${(0, _.browserDirectoryToMarkerFilePath)(browserDirectory)} does not exist`)
|
|
97
|
+
});else promise.resolve({
|
|
98
|
+
error: null
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
cp.on('error', error => {
|
|
102
|
+
promise.resolve({
|
|
103
|
+
error
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
_debugLogger.debugLogger.log('install', `running download:`);
|
|
107
|
+
_debugLogger.debugLogger.log('install', `-- from url: ${url}`);
|
|
108
|
+
_debugLogger.debugLogger.log('install', `-- to location: ${zipPath}`);
|
|
109
|
+
const downloadParams = {
|
|
110
|
+
title,
|
|
111
|
+
browserDirectory,
|
|
112
|
+
url,
|
|
113
|
+
zipPath,
|
|
114
|
+
executablePath,
|
|
115
|
+
connectionTimeout,
|
|
116
|
+
userAgent: (0, _userAgent.getUserAgent)()
|
|
117
|
+
};
|
|
118
|
+
cp.send({
|
|
119
|
+
method: 'download',
|
|
120
|
+
params: downloadParams
|
|
121
|
+
});
|
|
122
|
+
return promise;
|
|
123
|
+
}
|
|
124
|
+
function logPolitely(toBeLogged) {
|
|
125
|
+
const logLevel = process.env.npm_config_loglevel;
|
|
126
|
+
const logLevelDisplay = ['silent', 'error', 'warn'].indexOf(logLevel || '') > -1;
|
|
127
|
+
if (!logLevelDisplay) console.log(toBeLogged); // eslint-disable-line no-console
|
|
128
|
+
}
|
|
129
|
+
function getDownloadProgress() {
|
|
130
|
+
if (process.stdout.isTTY) return getAnimatedDownloadProgress();
|
|
131
|
+
return getBasicDownloadProgress();
|
|
132
|
+
}
|
|
133
|
+
function getAnimatedDownloadProgress() {
|
|
134
|
+
let progressBar;
|
|
135
|
+
let lastDownloadedBytes = 0;
|
|
136
|
+
return (downloadedBytes, totalBytes) => {
|
|
137
|
+
if (!progressBar) {
|
|
138
|
+
progressBar = new _utilsBundle.progress(`${toMegabytes(totalBytes)} [:bar] :percent :etas`, {
|
|
139
|
+
complete: '=',
|
|
140
|
+
incomplete: ' ',
|
|
141
|
+
width: 20,
|
|
142
|
+
total: totalBytes
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const delta = downloadedBytes - lastDownloadedBytes;
|
|
146
|
+
lastDownloadedBytes = downloadedBytes;
|
|
147
|
+
progressBar.tick(delta);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function getBasicDownloadProgress() {
|
|
151
|
+
const totalRows = 10;
|
|
152
|
+
const stepWidth = 8;
|
|
153
|
+
let lastRow = -1;
|
|
154
|
+
return (downloadedBytes, totalBytes) => {
|
|
155
|
+
const percentage = downloadedBytes / totalBytes;
|
|
156
|
+
const row = Math.floor(totalRows * percentage);
|
|
157
|
+
if (row > lastRow) {
|
|
158
|
+
lastRow = row;
|
|
159
|
+
const percentageString = String(percentage * 100 | 0).padStart(3);
|
|
160
|
+
// eslint-disable-next-line no-console
|
|
161
|
+
console.log(`|${'■'.repeat(row * stepWidth)}${' '.repeat((totalRows - row) * stepWidth)}| ${percentageString}% of ${toMegabytes(totalBytes)}`);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function toMegabytes(bytes) {
|
|
166
|
+
const mb = bytes / 1024 / 1024;
|
|
167
|
+
return `${Math.round(mb * 10) / 10} MiB`;
|
|
168
|
+
}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dockerVersion = dockerVersion;
|
|
7
|
+
exports.installDependenciesLinux = installDependenciesLinux;
|
|
8
|
+
exports.installDependenciesWindows = installDependenciesWindows;
|
|
9
|
+
exports.readDockerVersionSync = readDockerVersionSync;
|
|
10
|
+
exports.transformCommandsForRoot = transformCommandsForRoot;
|
|
11
|
+
exports.validateDependenciesLinux = validateDependenciesLinux;
|
|
12
|
+
exports.validateDependenciesWindows = validateDependenciesWindows;
|
|
13
|
+
exports.writeDockerVersion = writeDockerVersion;
|
|
14
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
15
|
+
var _path = _interopRequireDefault(require("path"));
|
|
16
|
+
var os = _interopRequireWildcard(require("os"));
|
|
17
|
+
var _child_process = _interopRequireDefault(require("child_process"));
|
|
18
|
+
var utils = _interopRequireWildcard(require("../../utils"));
|
|
19
|
+
var _spawnAsync = require("../../utils/spawnAsync");
|
|
20
|
+
var _hostPlatform = require("../../utils/hostPlatform");
|
|
21
|
+
var _ = require(".");
|
|
22
|
+
var _nativeDeps = require("./nativeDeps");
|
|
23
|
+
var _userAgent = require("../../utils/userAgent");
|
|
24
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
25
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
/**
|
|
28
|
+
* Copyright (c) Microsoft Corporation.
|
|
29
|
+
*
|
|
30
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
31
|
+
* you may not use this file except in compliance with the License.
|
|
32
|
+
* You may obtain a copy of the License at
|
|
33
|
+
*
|
|
34
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
35
|
+
*
|
|
36
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
37
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
38
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
39
|
+
* See the License for the specific language governing permissions and
|
|
40
|
+
* limitations under the License.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
const BIN_DIRECTORY = _path.default.join(__dirname, '..', '..', '..', 'bin');
|
|
44
|
+
const languageBindingVersion = process.env.PW_CLI_DISPLAY_VERSION || require('../../../package.json').version;
|
|
45
|
+
const dockerVersionFilePath = '/ms-playwright/.docker-info';
|
|
46
|
+
async function writeDockerVersion(dockerImageNameTemplate) {
|
|
47
|
+
await _fs.default.promises.mkdir(_path.default.dirname(dockerVersionFilePath), {
|
|
48
|
+
recursive: true
|
|
49
|
+
});
|
|
50
|
+
await _fs.default.promises.writeFile(dockerVersionFilePath, JSON.stringify(dockerVersion(dockerImageNameTemplate), null, 2), 'utf8');
|
|
51
|
+
// Make sure version file is globally accessible.
|
|
52
|
+
await _fs.default.promises.chmod(dockerVersionFilePath, 0o777);
|
|
53
|
+
}
|
|
54
|
+
function dockerVersion(dockerImageNameTemplate) {
|
|
55
|
+
return {
|
|
56
|
+
driverVersion: languageBindingVersion,
|
|
57
|
+
dockerImageName: dockerImageNameTemplate.replace('%version%', languageBindingVersion)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function readDockerVersionSync() {
|
|
61
|
+
try {
|
|
62
|
+
const data = JSON.parse(_fs.default.readFileSync(dockerVersionFilePath, 'utf8'));
|
|
63
|
+
return {
|
|
64
|
+
...data,
|
|
65
|
+
dockerImageNameTemplate: data.dockerImageName.replace(data.driverVersion, '%version%')
|
|
66
|
+
};
|
|
67
|
+
} catch (e) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const checkExecutable = filePath => {
|
|
72
|
+
if (process.platform === 'win32') return filePath.endsWith('.exe');
|
|
73
|
+
return _fs.default.promises.access(filePath, _fs.default.constants.X_OK).then(() => true).catch(() => false);
|
|
74
|
+
};
|
|
75
|
+
function isSupportedWindowsVersion() {
|
|
76
|
+
if (os.platform() !== 'win32' || os.arch() !== 'x64') return false;
|
|
77
|
+
const [major, minor] = os.release().split('.').map(token => parseInt(token, 10));
|
|
78
|
+
// This is based on: https://stackoverflow.com/questions/42524606/how-to-get-windows-version-using-node-js/44916050#44916050
|
|
79
|
+
// The table with versions is taken from: https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexw#remarks
|
|
80
|
+
// Windows 7 is not supported and is encoded as `6.1`.
|
|
81
|
+
return major > 6 || major === 6 && minor > 1;
|
|
82
|
+
}
|
|
83
|
+
async function installDependenciesWindows(targets, dryRun) {
|
|
84
|
+
if (targets.has('chromium')) {
|
|
85
|
+
const command = 'powershell.exe';
|
|
86
|
+
const args = ['-ExecutionPolicy', 'Bypass', '-File', _path.default.join(BIN_DIRECTORY, 'install_media_pack.ps1')];
|
|
87
|
+
if (dryRun) {
|
|
88
|
+
console.log(`${command} ${quoteProcessArgs(args).join(' ')}`); // eslint-disable-line no-console
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const {
|
|
92
|
+
code
|
|
93
|
+
} = await (0, _spawnAsync.spawnAsync)(command, args, {
|
|
94
|
+
cwd: BIN_DIRECTORY,
|
|
95
|
+
stdio: 'inherit'
|
|
96
|
+
});
|
|
97
|
+
if (code !== 0) throw new Error('Failed to install windows dependencies!');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function installDependenciesLinux(targets, dryRun) {
|
|
101
|
+
const libraries = [];
|
|
102
|
+
const platform = _hostPlatform.hostPlatform;
|
|
103
|
+
if (!_hostPlatform.isOfficiallySupportedPlatform) console.warn(`BEWARE: your OS is not officially supported by Playwright; installing dependencies for ${platform} as a fallback.`); // eslint-disable-line no-console
|
|
104
|
+
for (const target of targets) {
|
|
105
|
+
const info = _nativeDeps.deps[platform];
|
|
106
|
+
if (!info) {
|
|
107
|
+
console.warn(`Cannot install dependencies for ${platform}!`); // eslint-disable-line no-console
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
libraries.push(...info[target]);
|
|
111
|
+
}
|
|
112
|
+
const uniqueLibraries = Array.from(new Set(libraries));
|
|
113
|
+
if (!dryRun) console.log(`Installing dependencies...`); // eslint-disable-line no-console
|
|
114
|
+
const commands = [];
|
|
115
|
+
commands.push('apt-get update');
|
|
116
|
+
commands.push(['apt-get', 'install', '-y', '--no-install-recommends', ...uniqueLibraries].join(' '));
|
|
117
|
+
const {
|
|
118
|
+
command,
|
|
119
|
+
args,
|
|
120
|
+
elevatedPermissions
|
|
121
|
+
} = await transformCommandsForRoot(commands);
|
|
122
|
+
if (dryRun) {
|
|
123
|
+
console.log(`${command} ${quoteProcessArgs(args).join(' ')}`); // eslint-disable-line no-console
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (elevatedPermissions) console.log('Switching to root user to install dependencies...'); // eslint-disable-line no-console
|
|
127
|
+
const child = _child_process.default.spawn(command, args, {
|
|
128
|
+
stdio: 'inherit'
|
|
129
|
+
});
|
|
130
|
+
await new Promise((resolve, reject) => {
|
|
131
|
+
child.on('exit', code => code === 0 ? resolve() : reject(new Error(`Installation process exited with code: ${code}`)));
|
|
132
|
+
child.on('error', reject);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
async function validateDependenciesWindows(windowsExeAndDllDirectories) {
|
|
136
|
+
const directoryPaths = windowsExeAndDllDirectories;
|
|
137
|
+
const lddPaths = [];
|
|
138
|
+
for (const directoryPath of directoryPaths) lddPaths.push(...(await executablesOrSharedLibraries(directoryPath)));
|
|
139
|
+
const allMissingDeps = await Promise.all(lddPaths.map(lddPath => missingFileDependenciesWindows(lddPath)));
|
|
140
|
+
const missingDeps = new Set();
|
|
141
|
+
for (const deps of allMissingDeps) {
|
|
142
|
+
for (const dep of deps) missingDeps.add(dep);
|
|
143
|
+
}
|
|
144
|
+
if (!missingDeps.size) return;
|
|
145
|
+
let isCrtMissing = false;
|
|
146
|
+
let isMediaFoundationMissing = false;
|
|
147
|
+
for (const dep of missingDeps) {
|
|
148
|
+
if (dep.startsWith('api-ms-win-crt') || dep === 'vcruntime140.dll' || dep === 'vcruntime140_1.dll' || dep === 'msvcp140.dll') isCrtMissing = true;else if (dep === 'mf.dll' || dep === 'mfplat.dll' || dep === 'msmpeg2vdec.dll' || dep === 'evr.dll' || dep === 'avrt.dll') isMediaFoundationMissing = true;
|
|
149
|
+
}
|
|
150
|
+
const details = [];
|
|
151
|
+
if (isCrtMissing) {
|
|
152
|
+
details.push(`Some of the Universal C Runtime files cannot be found on the system. You can fix`, `that by installing Microsoft Visual C++ Redistributable for Visual Studio from:`, `https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads`, ``);
|
|
153
|
+
}
|
|
154
|
+
if (isMediaFoundationMissing) {
|
|
155
|
+
details.push(`Some of the Media Foundation files cannot be found on the system. If you are`, `on Windows Server try fixing this by running the following command in PowerShell`, `as Administrator:`, ``, ` Install-WindowsFeature Server-Media-Foundation`, ``, `For Windows N editions visit:`, `https://support.microsoft.com/en-us/help/3145500/media-feature-pack-list-for-windows-n-editions`, ``);
|
|
156
|
+
}
|
|
157
|
+
details.push(`Full list of missing libraries:`, ` ${[...missingDeps].join('\n ')}`, ``);
|
|
158
|
+
const message = `Host system is missing dependencies!\n\n${details.join('\n')}`;
|
|
159
|
+
if (isSupportedWindowsVersion()) {
|
|
160
|
+
throw new Error(message);
|
|
161
|
+
} else {
|
|
162
|
+
// eslint-disable-next-line no-console
|
|
163
|
+
console.warn(`WARNING: running on unsupported windows version!`);
|
|
164
|
+
// eslint-disable-next-line no-console
|
|
165
|
+
console.warn(message);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async function validateDependenciesLinux(sdkLanguage, linuxLddDirectories, dlOpenLibraries) {
|
|
169
|
+
var _deps$hostPlatform, _process$getuid, _process;
|
|
170
|
+
const directoryPaths = linuxLddDirectories;
|
|
171
|
+
const lddPaths = [];
|
|
172
|
+
for (const directoryPath of directoryPaths) lddPaths.push(...(await executablesOrSharedLibraries(directoryPath)));
|
|
173
|
+
const missingDepsPerFile = await Promise.all(lddPaths.map(lddPath => missingFileDependencies(lddPath, directoryPaths)));
|
|
174
|
+
const missingDeps = new Set();
|
|
175
|
+
for (const deps of missingDepsPerFile) {
|
|
176
|
+
for (const dep of deps) missingDeps.add(dep);
|
|
177
|
+
}
|
|
178
|
+
for (const dep of await missingDLOPENLibraries(dlOpenLibraries)) missingDeps.add(dep);
|
|
179
|
+
if (!missingDeps.size) return;
|
|
180
|
+
const allMissingDeps = new Set(missingDeps);
|
|
181
|
+
// Check Ubuntu version.
|
|
182
|
+
const missingPackages = new Set();
|
|
183
|
+
const libraryToPackageNameMapping = _nativeDeps.deps[_hostPlatform.hostPlatform] ? {
|
|
184
|
+
...(((_deps$hostPlatform = _nativeDeps.deps[_hostPlatform.hostPlatform]) === null || _deps$hostPlatform === void 0 ? void 0 : _deps$hostPlatform.lib2package) || {}),
|
|
185
|
+
...MANUAL_LIBRARY_TO_PACKAGE_NAME_UBUNTU
|
|
186
|
+
} : {};
|
|
187
|
+
// Translate missing dependencies to package names to install with apt.
|
|
188
|
+
for (const missingDep of missingDeps) {
|
|
189
|
+
const packageName = libraryToPackageNameMapping[missingDep];
|
|
190
|
+
if (packageName) {
|
|
191
|
+
missingPackages.add(packageName);
|
|
192
|
+
missingDeps.delete(missingDep);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const maybeSudo = (_process$getuid = (_process = process).getuid) !== null && _process$getuid !== void 0 && _process$getuid.call(_process) && os.platform() !== 'win32' ? 'sudo ' : '';
|
|
196
|
+
const dockerInfo = readDockerVersionSync();
|
|
197
|
+
const errorLines = [`Host system is missing dependencies to run browsers.`];
|
|
198
|
+
// Ignore patch versions when comparing docker container version and Playwright version:
|
|
199
|
+
// we **NEVER** roll browsers in patch releases, so native dependencies do not change.
|
|
200
|
+
if (dockerInfo && !dockerInfo.driverVersion.startsWith((0, _userAgent.getPlaywrightVersion)(true /* majorMinorOnly */) + '.')) {
|
|
201
|
+
// We are running in a docker container with unmatching version.
|
|
202
|
+
// In this case, we know how to install dependencies in it.
|
|
203
|
+
const pwVersion = (0, _userAgent.getPlaywrightVersion)();
|
|
204
|
+
const requiredDockerImage = dockerInfo.dockerImageName.replace(dockerInfo.driverVersion, pwVersion);
|
|
205
|
+
errorLines.push(...[`This is most likely due to Docker image version not matching Playwright version:`, `- Playwright : ${pwVersion}`, `- Docker image: ${dockerInfo.driverVersion}`, ``, `Either:`, `- (recommended) use Docker image "${requiredDockerImage}"`, `- (alternative 1) run the following command inside Docker to install missing dependencies:`, ``, ` ${maybeSudo}${(0, _.buildPlaywrightCLICommand)(sdkLanguage, 'install-deps')}`, ``, `- (alternative 2) use apt inside Docker:`, ``, ` ${maybeSudo}apt-get install ${[...missingPackages].join('\\\n ')}`, ``, `<3 Playwright Team`]);
|
|
206
|
+
} else if (missingPackages.size && !missingDeps.size) {
|
|
207
|
+
// Only known dependencies are missing for browsers.
|
|
208
|
+
// Suggest installation with a Playwright CLI.
|
|
209
|
+
errorLines.push(...[`Please install them with the following command:`, ``, ` ${maybeSudo}${(0, _.buildPlaywrightCLICommand)(sdkLanguage, 'install-deps')}`, ``, `Alternatively, use apt:`, ` ${maybeSudo}apt-get install ${[...missingPackages].join('\\\n ')}`, ``, `<3 Playwright Team`]);
|
|
210
|
+
} else {
|
|
211
|
+
// Unhappy path: we either run on unknown distribution, or we failed to resolve all missing
|
|
212
|
+
// libraries to package names.
|
|
213
|
+
// Print missing libraries only:
|
|
214
|
+
errorLines.push(...[`Missing libraries:`, ...[...allMissingDeps].map(dep => ' ' + dep)]);
|
|
215
|
+
}
|
|
216
|
+
throw new Error('\n' + utils.wrapInASCIIBox(errorLines.join('\n'), 1));
|
|
217
|
+
}
|
|
218
|
+
function isSharedLib(basename) {
|
|
219
|
+
switch (os.platform()) {
|
|
220
|
+
case 'linux':
|
|
221
|
+
return basename.endsWith('.so') || basename.includes('.so.');
|
|
222
|
+
case 'win32':
|
|
223
|
+
return basename.endsWith('.dll');
|
|
224
|
+
default:
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async function executablesOrSharedLibraries(directoryPath) {
|
|
229
|
+
if (!_fs.default.existsSync(directoryPath)) return [];
|
|
230
|
+
const allPaths = (await _fs.default.promises.readdir(directoryPath)).map(file => _path.default.resolve(directoryPath, file));
|
|
231
|
+
const allStats = await Promise.all(allPaths.map(aPath => _fs.default.promises.stat(aPath)));
|
|
232
|
+
const filePaths = allPaths.filter((aPath, index) => allStats[index].isFile());
|
|
233
|
+
const executablersOrLibraries = (await Promise.all(filePaths.map(async filePath => {
|
|
234
|
+
const basename = _path.default.basename(filePath).toLowerCase();
|
|
235
|
+
if (isSharedLib(basename)) return filePath;
|
|
236
|
+
if (await checkExecutable(filePath)) return filePath;
|
|
237
|
+
return false;
|
|
238
|
+
}))).filter(Boolean);
|
|
239
|
+
return executablersOrLibraries;
|
|
240
|
+
}
|
|
241
|
+
async function missingFileDependenciesWindows(filePath) {
|
|
242
|
+
const executable = _path.default.join(__dirname, '..', '..', '..', 'bin', 'PrintDeps.exe');
|
|
243
|
+
const dirname = _path.default.dirname(filePath);
|
|
244
|
+
const {
|
|
245
|
+
stdout,
|
|
246
|
+
code
|
|
247
|
+
} = await (0, _spawnAsync.spawnAsync)(executable, [filePath], {
|
|
248
|
+
cwd: dirname,
|
|
249
|
+
env: {
|
|
250
|
+
...process.env,
|
|
251
|
+
LD_LIBRARY_PATH: process.env.LD_LIBRARY_PATH ? `${process.env.LD_LIBRARY_PATH}:${dirname}` : dirname
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
if (code !== 0) return [];
|
|
255
|
+
const missingDeps = stdout.split('\n').map(line => line.trim()).filter(line => line.endsWith('not found') && line.includes('=>')).map(line => line.split('=>')[0].trim().toLowerCase());
|
|
256
|
+
return missingDeps;
|
|
257
|
+
}
|
|
258
|
+
async function missingFileDependencies(filePath, extraLDPaths) {
|
|
259
|
+
const dirname = _path.default.dirname(filePath);
|
|
260
|
+
let LD_LIBRARY_PATH = extraLDPaths.join(':');
|
|
261
|
+
if (process.env.LD_LIBRARY_PATH) LD_LIBRARY_PATH = `${process.env.LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}`;
|
|
262
|
+
const {
|
|
263
|
+
stdout,
|
|
264
|
+
code
|
|
265
|
+
} = await (0, _spawnAsync.spawnAsync)('ldd', [filePath], {
|
|
266
|
+
cwd: dirname,
|
|
267
|
+
env: {
|
|
268
|
+
...process.env,
|
|
269
|
+
LD_LIBRARY_PATH
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
if (code !== 0) return [];
|
|
273
|
+
const missingDeps = stdout.split('\n').map(line => line.trim()).filter(line => line.endsWith('not found') && line.includes('=>')).map(line => line.split('=>')[0].trim());
|
|
274
|
+
return missingDeps;
|
|
275
|
+
}
|
|
276
|
+
async function missingDLOPENLibraries(libraries) {
|
|
277
|
+
if (!libraries.length) return [];
|
|
278
|
+
// NOTE: Using full-qualified path to `ldconfig` since `/sbin` is not part of the
|
|
279
|
+
// default PATH in CRON.
|
|
280
|
+
// @see https://github.com/microsoft/playwright/issues/3397
|
|
281
|
+
const {
|
|
282
|
+
stdout,
|
|
283
|
+
code,
|
|
284
|
+
error
|
|
285
|
+
} = await (0, _spawnAsync.spawnAsync)('/sbin/ldconfig', ['-p'], {});
|
|
286
|
+
if (code !== 0 || error) return [];
|
|
287
|
+
const isLibraryAvailable = library => stdout.toLowerCase().includes(library.toLowerCase());
|
|
288
|
+
return libraries.filter(library => !isLibraryAvailable(library));
|
|
289
|
+
}
|
|
290
|
+
const MANUAL_LIBRARY_TO_PACKAGE_NAME_UBUNTU = {
|
|
291
|
+
// libgstlibav.so (the only actual library provided by gstreamer1.0-libav) is not
|
|
292
|
+
// in the ldconfig cache, so we detect the actual library required for playing h.264
|
|
293
|
+
// and if it's missing recommend installing missing gstreamer lib.
|
|
294
|
+
// gstreamer1.0-libav -> libavcodec57 -> libx264-152
|
|
295
|
+
'libx264.so': 'gstreamer1.0-libav'
|
|
296
|
+
};
|
|
297
|
+
function quoteProcessArgs(args) {
|
|
298
|
+
return args.map(arg => {
|
|
299
|
+
if (arg.includes(' ')) return `"${arg}"`;
|
|
300
|
+
return arg;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
async function transformCommandsForRoot(commands) {
|
|
304
|
+
var _process$getuid2, _process2;
|
|
305
|
+
const isRoot = ((_process$getuid2 = (_process2 = process).getuid) === null || _process$getuid2 === void 0 ? void 0 : _process$getuid2.call(_process2)) === 0;
|
|
306
|
+
if (isRoot) return {
|
|
307
|
+
command: 'sh',
|
|
308
|
+
args: ['-c', `${commands.join('&& ')}`],
|
|
309
|
+
elevatedPermissions: false
|
|
310
|
+
};
|
|
311
|
+
const sudoExists = await (0, _spawnAsync.spawnAsync)('which', ['sudo']);
|
|
312
|
+
if (sudoExists.code === 0) return {
|
|
313
|
+
command: 'sudo',
|
|
314
|
+
args: ['--', 'sh', '-c', `${commands.join('&& ')}`],
|
|
315
|
+
elevatedPermissions: true
|
|
316
|
+
};
|
|
317
|
+
return {
|
|
318
|
+
command: 'su',
|
|
319
|
+
args: ['root', '-c', `${commands.join('&& ')}`],
|
|
320
|
+
elevatedPermissions: true
|
|
321
|
+
};
|
|
322
|
+
}
|