@replayio/replay
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "@replayio/replay", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "CLI tool for uploading and managing recordings", | ||
@@ -26,3 +26,3 @@ "bin": { | ||
}, | ||
"gitHead": "970d3c7c36d46b494d113e124efebcec66f06212" | ||
"gitHead": "dc1dc2f0a82f39b67070ad3d675605064ab504d6" | ||
} |
@@ -7,3 +7,3 @@ // Manage installation of browsers for other NPM packages. | ||
const path = require("path"); | ||
const { defer, getDirectory } = require("./utils"); | ||
const { defer, getDirectory, maybeLog } = require("./utils"); | ||
@@ -16,15 +16,21 @@ const EXECUTABLE_PATHS = { | ||
async function ensurePlaywrightBrowsersInstalled(kind = "all") { | ||
async function ensurePlaywrightBrowsersInstalled(kind = "all", opts = {}) { | ||
maybeLog(opts.verbose, `Installing ${kind === "all" ? "browsers" : kind} for ${process.platform}`); | ||
if (kind !== "all" && !getPlatformKey(kind)) { | ||
console.log(`${kind} browser for Replay is not supported on ${process.platform}`); | ||
return; | ||
} | ||
switch (process.platform) { | ||
case "darwin": | ||
if (["all", "gecko"].includes(kind)) { | ||
await installReplayBrowser("macOS-replay-playwright.tar.xz", "playwright", "firefox", "firefox"); | ||
if (["all", "firefox"].includes(kind)) { | ||
await installReplayBrowser("macOS-replay-playwright.tar.xz", "playwright", "firefox", "firefox", opts); | ||
} | ||
break; | ||
case "linux": | ||
if (["all", "gecko"].includes(kind)) { | ||
await installReplayBrowser("linux-replay-playwright.tar.xz", "playwright", "firefox", "firefox"); | ||
if (["all", "firefox"].includes(kind)) { | ||
await installReplayBrowser("linux-replay-playwright.tar.xz", "playwright", "firefox", "firefox", opts); | ||
} | ||
if (["all", "chromium"].includes(kind)) { | ||
await installReplayBrowser("linux-replay-chromium.tar.xz", "playwright", "replay-chromium", "chrome-linux"); | ||
await installReplayBrowser("linux-replay-chromium.tar.xz", "playwright", "replay-chromium", "chrome-linux", opts); | ||
} | ||
@@ -91,3 +97,3 @@ break; | ||
// Installs a browser if it isn't already installed. | ||
async function installReplayBrowser(name, subdir, srcName, dstName) { | ||
async function installReplayBrowser(name, subdir, srcName, dstName, opts) { | ||
const replayDir = getDirectory(); | ||
@@ -97,6 +103,7 @@ const browserDir = path.join(replayDir, subdir); | ||
if (fs.existsSync(path.join(browserDir, dstName))) { | ||
maybeLog(opts.verbose, `Skipping ${dstName}. Already exists in ${browserDir}`); | ||
return; | ||
} | ||
const contents = await downloadReplayFile(name); | ||
const contents = await downloadReplayFile(name, opts); | ||
@@ -108,2 +115,4 @@ for (const dir of [replayDir, browserDir]) { | ||
} | ||
maybeLog(opts.verbose, `Saving ${dstName} to ${browserDir}`); | ||
fs.writeFileSync(path.join(browserDir, name), contents); | ||
@@ -129,17 +138,12 @@ spawnSync("tar", ["xf", name], { cwd: browserDir }); | ||
} else { | ||
maybeLog(opts.verbose, `Browser ${name} is not installed.`); | ||
return; | ||
} | ||
if (opts.verbose) { | ||
console.log(`Updating browser ${subdir} ${dstName}...`); | ||
} | ||
await installReplayBrowser(name, subdir, srcName, dstName, opts); | ||
await installReplayBrowser(name, subdir, srcName, dstName); | ||
if (opts.verbose) { | ||
console.log(`Updated.`); | ||
} | ||
maybeLog(opts.verbose, `Updated.`); | ||
} | ||
async function downloadReplayFile(downloadFile) { | ||
async function downloadReplayFile(downloadFile, opts) { | ||
const options = { | ||
@@ -153,2 +157,3 @@ host: "static.replay.io", | ||
const waiter = defer(); | ||
maybeLog(opts.verbose, `Downloading ${downloadFile} from replay.io (Attempt ${i + 1} / 5)`); | ||
const request = https.get(options, response => { | ||
@@ -174,2 +179,4 @@ if (response.statusCode != 200) { | ||
} | ||
maybeLog(opts.verbose, `Download of ${downloadFile} complete`); | ||
} | ||
@@ -176,0 +183,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43525
1215