From f0fd6de133c204f37e7360f086acd0c5eae421a0 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Tue, 3 May 2022 19:08:04 -0400 Subject: [PATCH 1/9] fix(launcher): support Firefox as a snap --- packages/launcher/lib/linux/index.ts | 38 ++++++++++++++- packages/launcher/package.json | 5 +- packages/launcher/test/unit/linux_spec.ts | 37 ++++++++++++++- yarn.lock | 57 ++++++++++++++--------- 4 files changed, 110 insertions(+), 27 deletions(-) diff --git a/packages/launcher/lib/linux/index.ts b/packages/launcher/lib/linux/index.ts index c09fca1dd308..c16b7177c7c5 100644 --- a/packages/launcher/lib/linux/index.ts +++ b/packages/launcher/lib/linux/index.ts @@ -3,8 +3,28 @@ import type { FoundBrowser, Browser, PathData } from '../types' import { notInstalledErr } from '../errors' import { utils } from '../utils' import os from 'os' +import { promises as fs } from 'fs' import path from 'path' import Bluebird from 'bluebird' +import which from 'which' + +async function isFirefoxSnap (binary: string): Promise { + try { + const binaryPath = await which(binary) + + // read the first 16kb, don't read the entire file into memory in case it is a binary + const fd = await fs.open(binaryPath, 'r') + const { buffer, bytesRead } = await fd.read({ length: 16384 }) + + fd.close() + + return buffer.slice(0, bytesRead).toString('utf8').includes('exec /snap/bin/firefox') + } catch (err) { + log('failed to check if Firefox is a snap, assuming it isn\'t %o', { err, binary }) + + return false + } +} function getLinuxBrowser ( name: string, @@ -43,11 +63,25 @@ function getLinuxBrowser ( throw notInstalledErr(binary) } - const maybeSetSnapProfilePath = (versionString: string) => { - if (os.platform() === 'linux' && name === 'chromium' && versionString.endsWith('snap')) { + const maybeSetSnapProfilePath = async (versionString: string) => { + if (os.platform() !== 'linux') return + + if (name === 'chromium' && versionString.endsWith('snap')) { // when running as a snap, chromium can only write to certain directories // @see https://github.com/cypress-io/cypress/issues/7020 + log('chromium is running as a snap, changing profile path') foundBrowser.profilePath = path.join(os.homedir(), 'snap', 'chromium', 'current') + + return + } + + if (name === 'firefox' && (await isFirefoxSnap(binary))) { + // if the binary in the path points to a script that calls the snap, set a snap-specific profile path + // @see https://github.com/cypress-io/cypress/issues/19793 + log('firefox is running as a snap, changing profile path') + foundBrowser.profilePath = path.join(os.homedir(), 'snap', 'firefox', 'current') + + return } } diff --git a/packages/launcher/package.json b/packages/launcher/package.json index 065b990a924e..62c48b0b5e4f 100644 --- a/packages/launcher/package.json +++ b/packages/launcher/package.json @@ -18,14 +18,15 @@ "fs-extra": "9.1.0", "lodash": "^4.17.21", "plist": "3.0.5", - "semver": "7.3.5" + "semver": "7.3.5", + "which": "2.0.2" }, "devDependencies": { "@packages/ts": "0.0.0-development", "chai": "3.5.0", "chai-as-promised": "7.1.1", "mocha": "3.5.3", - "shelljs": "0.8.5", + "mock-fs": "5.1.2", "sinon": "^10.0.0", "sinon-chai": "3.4.0", "typescript": "^4.2.3" diff --git a/packages/launcher/test/unit/linux_spec.ts b/packages/launcher/test/unit/linux_spec.ts index cc8db36aa36f..2631306cd7d6 100644 --- a/packages/launcher/test/unit/linux_spec.ts +++ b/packages/launcher/test/unit/linux_spec.ts @@ -10,12 +10,13 @@ import { expect } from 'chai' import { utils } from '../../lib/utils' import os from 'os' import sinon, { SinonStub } from 'sinon' +import mockFs from 'mock-fs' describe('linux browser detection', () => { let execa: SinonStub + let cachedEnv = { ...process.env } beforeEach(() => { - sinon.restore() execa = sinon.stub(utils, 'getOutput') sinon.stub(os, 'platform').returns('linux') @@ -34,6 +35,12 @@ describe('linux browser detection', () => { .resolves({ stdout: 'foo-browser v9001.1.2.3' }) }) + afterEach(() => { + Object.assign(process.env, cachedEnv) + mockFs.restore() + sinon.restore() + }) + it('detects browser by running --version', () => { const goal = goalBrowsers[0] const checkBrowser = (browser) => { @@ -72,6 +79,34 @@ describe('linux browser detection', () => { return detect().then(checkBrowser) }) + // https://github.com/cypress-io/cypress/issues/19793 + it('sets profilePath on snapcraft firefox', async () => { + process.env.PATH = '/bin' + mockFs({ + '/bin/firefox': mockFs.symlink({ path: '/usr/bin/firefox' }), + '/usr/bin/firefox': mockFs.file({ mode: 0o777, content: 'foo bar foo bar foo bar\nexec /snap/bin/firefox\n' }), + }) + + execa.withArgs('firefox', ['--version']) + .resolves({ stdout: 'Mozilla Firefox 99.2.3' }) + + sinon.stub(os, 'homedir').returns('/home/foo') + + const [browser] = await detect() + + expect(browser).to.deep.equal({ + channel: 'stable', + name: 'firefox', + family: 'firefox', + displayName: 'Firefox', + majorVersion: 99, + minSupportedVersion: 86, + path: 'firefox', + profilePath: '/home/foo/snap/firefox/current', + version: '99.2.3', + }) + }) + // https://github.com/cypress-io/cypress/issues/6669 it('detects browser if the --version stdout is multiline', () => { execa.withArgs('multiline-foo', ['--version']) diff --git a/yarn.lock b/yarn.lock index 2a714f8a300f..cb4d9c030e71 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4138,7 +4138,7 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^13.0.0" -"@jest/types@^26.3.0", "@jest/types@^26.6.2": +"@jest/types@^26.6.2": version "26.6.2" resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" integrity sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ== @@ -8268,7 +8268,7 @@ "@types/cheerio@*", "@types/cheerio@0.22.21": version "0.22.21" - resolved "https://registry.yarnpkg.com/@types/cheerio/-/cheerio-0.22.21.tgz#5e37887de309ba11b2e19a6e14cad7874b31a8a3" + resolved "https://registry.npmjs.org/@types/cheerio/-/cheerio-0.22.21.tgz#5e37887de309ba11b2e19a6e14cad7874b31a8a3" integrity sha512-aGI3DfswwqgKPiEOTaiHV2ZPC9KEhprpgEbJnv0fZl3SGX0cGgEva1126dGrMC6AJM6v/aihlUgJn9M5DbDZ/Q== dependencies: "@types/node" "*" @@ -8370,7 +8370,7 @@ "@types/enzyme@*", "@types/enzyme@3.10.5": version "3.10.5" - resolved "https://registry.yarnpkg.com/@types/enzyme/-/enzyme-3.10.5.tgz#fe7eeba3550369eed20e7fb565bfb74eec44f1f0" + resolved "https://registry.npmjs.org/@types/enzyme/-/enzyme-3.10.5.tgz#fe7eeba3550369eed20e7fb565bfb74eec44f1f0" integrity sha512-R+phe509UuUYy9Tk0YlSbipRpfVtIzb/9BHn5pTEtjJTF5LXvUjrIQcZvNyANNEyFrd2YGs196PniNT1fgvOQA== dependencies: "@types/cheerio" "*" @@ -10817,10 +10817,10 @@ ansi-regex@^3.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= -ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== +ansi-regex@^4.0.0, ansi-regex@^4.1.0: + version "4.1.1" + resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== ansi-regex@^5.0.0, ansi-regex@^5.0.1: version "5.0.1" @@ -14123,7 +14123,7 @@ collection-visit@^1.0.0: map-visit "^1.0.0" object-visit "^1.0.0" -color-convert@^1.9.0, color-convert@^1.9.1: +color-convert@^1.9.0, color-convert@^1.9.1, color-convert@^1.9.3: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -14147,7 +14147,7 @@ color-name@^1.0.0, color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -color-string@1.5.5, color-string@^1.5.4: +color-string@1.5.5: version "1.5.5" resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.5.5.tgz#65474a8f0e7439625f3d27a6a19d89fc45223014" integrity sha512-jgIoum0OfQfq9Whcfc2z/VhCNcmQjWbey6qBX0vqt7YICflUmBCh9E9CiQD5GSJ+Uehixm3NUwHVhqUAWRivZg== @@ -14155,18 +14155,26 @@ color-string@1.5.5, color-string@^1.5.4: color-name "^1.0.0" simple-swizzle "^0.2.2" +color-string@^1.5.4, color-string@^1.6.0: + version "1.9.1" + resolved "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz#4467f9146f036f855b764dfb5bf8582bf342c7a4" + integrity sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg== + dependencies: + color-name "^1.0.0" + simple-swizzle "^0.2.2" + color-support@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== color@^3.0.0, color@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/color/-/color-3.1.3.tgz#ca67fb4e7b97d611dcde39eceed422067d91596e" - integrity sha512-xgXAcTHa2HeFCGLE9Xs/R82hujGtu9Jd9x4NW3T34+OMs7VoPsjwzRczKHvTAHeJwWFwX5j15+MgAppE8ztObQ== + version "3.2.1" + resolved "https://registry.yarnpkg.com/color/-/color-3.2.1.tgz#3544dc198caf4490c3ecc9a790b54fe9ff45e164" + integrity sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA== dependencies: - color-convert "^1.9.1" - color-string "^1.5.4" + color-convert "^1.9.3" + color-string "^1.6.0" colorette@^1.1.0, colorette@^1.2.1, colorette@^1.2.2: version "1.2.2" @@ -27246,6 +27254,11 @@ mock-fs@5.1.1: resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-5.1.1.tgz#d4c95e916abf400664197079d7e399d133bb6048" integrity sha512-p/8oZ3qvfKGPw+4wdVCyjDxa6wn2tP0TCf3WXC1UyUBAevezPn1TtOoxtMYVbZu/S/iExg+Ghed1busItj2CEw== +mock-fs@5.1.2: + version "5.1.2" + resolved "https://registry.npmjs.org/mock-fs/-/mock-fs-5.1.2.tgz#6fa486e06d00f8793a8d2228de980eff93ce6db7" + integrity sha512-YkjQkdLulFrz0vD4BfNQdQRVmgycXTV7ykuHMlyv+C8WCHazpkiQRDthwa02kSyo8wKnY9wRptHfQLgmf0eR+A== + mock-require@3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/mock-require/-/mock-require-3.0.3.tgz#ccd544d9eae81dd576b3f219f69ec867318a1946" @@ -27755,9 +27768,9 @@ node-addon-api@^1.6.3: integrity sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg== node-addon-api@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.1.0.tgz#98b21931557466c6729e51cb77cd39c965f42239" - integrity sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw== + version "3.2.1" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161" + integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A== node-dir@^0.1.10: version "0.1.17" @@ -32458,7 +32471,7 @@ react-inspector@^5.1.0: is-dom "^1.0.0" prop-types "^15.0.0" -react-is@16.13.1, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.3.2, react-is@^16.7.0, react-is@^16.8.0, react-is@^16.8.1, react-is@^16.8.6: +react-is@16.13.1, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.3.2, react-is@^16.7.0, react-is@^16.8.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== @@ -35316,7 +35329,7 @@ socket.io-client@4.0.1: socket.io-parser@4.0.4, socket.io-parser@~3.3.0, socket.io-parser@~3.4.0, socket.io-parser@~4.0.3, socket.io-parser@~4.0.4: version "4.0.4" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.0.4.tgz#9ea21b0d61508d18196ef04a2c6b9ab630f4c2b0" + resolved "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.4.tgz#9ea21b0d61508d18196ef04a2c6b9ab630f4c2b0" integrity sha512-t+b0SS+IxG7Rxzda2EVvyBZbvFPBCjJoyHuE0P//7OAsN23GItzDRdWa6ALxZI/8R5ygK7jAR6t028/z+7295g== dependencies: "@types/component-emitter" "^1.2.10" @@ -37950,7 +37963,7 @@ typescript@^4.2.3, typescript@^4.4.4: ua-parser-js@0.7.24, ua-parser-js@^0.7.18: version "0.7.24" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.24.tgz#8d3ecea46ed4f1f1d63ec25f17d8568105dc027c" + resolved "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.24.tgz#8d3ecea46ed4f1f1d63ec25f17d8568105dc027c" integrity sha512-yo+miGzQx5gakzVK3QFfN0/L9uVhosXBBO7qmnk7c2iw1IhL212wfA3zbnI54B0obGwC/5NWub/iT9sReMx+Fw== uc.micro@^1.0.1, uc.micro@^1.0.5: @@ -39398,7 +39411,7 @@ vue-style-loader@^4.1.0, vue-style-loader@^4.1.2: vue-template-compiler@2.6.12, vue-template-compiler@^2.6.11: version "2.6.12" - resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.6.12.tgz#947ed7196744c8a5285ebe1233fe960437fcc57e" + resolved "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.12.tgz#947ed7196744c8a5285ebe1233fe960437fcc57e" integrity sha512-OzzZ52zS41YUbkCBfdXShQTe69j1gQDZ9HIX8miuC9C3rBCk9wIRjLiZZLrmX9V+Ftq/YEyv1JaVr5Y/hNtByg== dependencies: de-indent "^1.0.2" @@ -40324,7 +40337,7 @@ which@1.3.1, which@^1.1.1, which@^1.2.12, which@^1.2.14, which@^1.2.4, which@^1. which@2.0.2, which@^2.0.1, which@^2.0.2: version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + resolved "https://registry.npmjs.org/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== dependencies: isexe "^2.0.0" From 9a38223f3dfeb43d923e6ded36b802de1bdfa865 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Tue, 3 May 2022 19:16:21 -0400 Subject: [PATCH 2/9] upgrade @types/node --- npm/angular/package.json | 2 +- npm/create-cypress-tests/package.json | 2 +- npm/cypress-schematic/package.json | 2 +- npm/cypress-schematic/sandbox/package.json | 2 +- npm/design-system/package.json | 2 +- package.json | 2 +- packages/errors/package.json | 2 +- packages/runner-ct/package.json | 2 +- packages/server/package.json | 2 +- yarn.lock | 34 +++++++++++----------- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/npm/angular/package.json b/npm/angular/package.json index ac8e63ff17e8..d47a21dbd2d9 100644 --- a/npm/angular/package.json +++ b/npm/angular/package.json @@ -40,7 +40,7 @@ "@cypress/webpack-dev-server": "0.0.0-development", "@cypress/webpack-preprocessor": "5.7.0", "@types/cypress-image-snapshot": "3.1.5", - "@types/node": "8.10.66", + "@types/node": "16.11.7", "angular-router-loader": "0.8.5", "angular2-template-loader": "0.6.2", "codelyzer": "6.0.2", diff --git a/npm/create-cypress-tests/package.json b/npm/create-cypress-tests/package.json index dda6627a31f3..63a8077660f4 100644 --- a/npm/create-cypress-tests/package.json +++ b/npm/create-cypress-tests/package.json @@ -32,7 +32,7 @@ "@types/babel__core": "^7.1.2", "@types/inquirer": "7.3.1", "@types/mock-fs": "4.10.0", - "@types/node": "14.14.31", + "@types/node": "16.11.7", "@types/ora": "^3.2.0", "copy": "0.3.2", "mocha": "7.1.1", diff --git a/npm/cypress-schematic/package.json b/npm/cypress-schematic/package.json index 75068019a7b7..24032879b8e2 100644 --- a/npm/cypress-schematic/package.json +++ b/npm/cypress-schematic/package.json @@ -30,7 +30,7 @@ "@angular/cli": "^12", "@types/chai-enzyme": "0.6.7", "@types/mocha": "8.0.3", - "@types/node": "^12.11.1", + "@types/node": "16.11.7", "chai": "4.2.0", "cypress": "0.0.0-development", "mocha": "3.5.3", diff --git a/npm/cypress-schematic/sandbox/package.json b/npm/cypress-schematic/sandbox/package.json index 97dd845d8b85..b78f08f4fd61 100644 --- a/npm/cypress-schematic/sandbox/package.json +++ b/npm/cypress-schematic/sandbox/package.json @@ -27,7 +27,7 @@ "@angular/cli": "~12.0.0", "@angular/compiler-cli": "~12.0.0", "@types/jasmine": "~3.6.0", - "@types/node": "^12.11.1", + "@types/node": "16.11.7", "jasmine-core": "~3.7.0", "karma": "~6.3.0", "karma-chrome-launcher": "~3.1.0", diff --git a/npm/design-system/package.json b/npm/design-system/package.json index 99c9d353786f..68092324100a 100644 --- a/npm/design-system/package.json +++ b/npm/design-system/package.json @@ -56,7 +56,7 @@ "@storybook/preset-typescript": "^3.0.0", "@storybook/react": "^6.1.21", "@storybook/testing-react": "^0.0.12", - "@types/node": "14.14.31", + "@types/node": "16.11.7", "@types/react-virtualized-auto-sizer": "^1.0.0", "@types/react-window": "^1.8.2", "@types/semver": "7.3.4", diff --git a/package.json b/package.json index 6080eed75bc3..2d8f3e369879 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "@types/markdown-it": "0.0.9", "@types/mini-css-extract-plugin": "1.2.3", "@types/mocha": "8.0.3", - "@types/node": "14.14.31", + "@types/node": "16.11.7", "@types/prismjs": "1.16.0", "@types/react": "16.9.50", "@types/react-dom": "16.9.8", diff --git a/packages/errors/package.json b/packages/errors/package.json index d6909490b2ea..e50e6558664e 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -24,7 +24,7 @@ "@packages/ts": "0.0.0-development", "@types/chai": "4.2.15", "@types/mocha": "8.2.2", - "@types/node": "14.14.31", + "@types/node": "16.11.7", "@types/pngjs": "^6.0.1", "@types/strip-ansi": "^5.2.1", "ansi-styles": "^5", diff --git a/packages/runner-ct/package.json b/packages/runner-ct/package.json index d141eb17e82f..ab6507a7b96f 100644 --- a/packages/runner-ct/package.json +++ b/packages/runner-ct/package.json @@ -24,7 +24,7 @@ "@fortawesome/react-fontawesome": "^0.1.14", "@packages/driver": "0.0.0-development", "@types/http-proxy": "1.17.4", - "@types/node": "14.14.31", + "@types/node": "16.11.7", "@types/sockjs-client": "1.1.0", "babel-loader": "8.1.0", "bluebird": "3.5.3", diff --git a/packages/server/package.json b/packages/server/package.json index f253231ad479..b937f305a123 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -142,7 +142,7 @@ "@types/chai-as-promised": "7.1.2", "@types/chrome": "0.0.101", "@types/http-proxy": "1.17.4", - "@types/node": "14.14.31", + "@types/node": "16.11.7", "babel-loader": "8.1.0", "chai-as-promised": "7.1.1", "chai-subset": "1.6.0", diff --git a/yarn.lock b/yarn.lock index cb4d9c030e71..185224a3e290 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4138,9 +4138,9 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^13.0.0" -"@jest/types@^26.6.2": +"@jest/types@^26.3.0", "@jest/types@^26.6.2": version "26.6.2" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" + resolved "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" integrity sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ== dependencies: "@types/istanbul-lib-coverage" "^2.0.0" @@ -8717,26 +8717,26 @@ "@types/node" "*" form-data "^3.0.0" -"@types/node@*", "@types/node@>= 8", "@types/node@>=10.0.0": - version "15.0.1" - resolved "https://registry.npmjs.org/@types/node/-/node-15.0.1.tgz#ef34dea0881028d11398be5bf4e856743e3dc35a" - integrity sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA== +"@types/node@*", "@types/node@16.11.7", "@types/node@>= 8", "@types/node@>=10.0.0": + version "16.11.7" + resolved "https://registry.npmjs.org/@types/node/-/node-16.11.7.tgz#36820945061326978c42a01e56b61cd223dfdc42" + integrity sha512-QB5D2sqfSjCmTuWcBWyJ+/44bcjO7VbjSbOE0ucoVbAsSNQc4Lt6QkgkVXkTDwkL4z/beecZNDvVX15D4P8Jbw== + +"@types/node@^12.12.29": + version "12.20.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.12.tgz#fd9c1c2cfab536a2383ed1ef70f94adea743a226" + integrity sha512-KQZ1al2hKOONAs2MFv+yTQP1LkDWMrRJ9YCVRalXltOfXsBmH5IownLxQaiq0lnAHwAViLnh2aTYqrPcRGEbgg== -"@types/node@14.14.31", "@types/node@^14.0.10", "@types/node@^14.14.31", "@types/node@^14.6.2": +"@types/node@^14.0.10", "@types/node@^14.14.31", "@types/node@^14.6.2": version "14.14.31" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.31.tgz#72286bd33d137aa0d152d47ec7c1762563d34055" integrity sha512-vFHy/ezP5qI0rFgJ7aQnjDXwAMrG0KqqIH7tQG5PPv3BWBayOPIQNBjVc/P6hhdZfMx51REc6tfDNXHUio893g== -"@types/node@8.10.66", "@types/node@^8.0.7": +"@types/node@^8.0.7": version "8.10.66" resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.66.tgz#dd035d409df322acc83dff62a602f12a5783bbb3" integrity sha512-tktOkFUA4kXx2hhhrB8bIFb5TbwzS4uOhKEmwiD+NoiL0qtP2OQ9mFldbgD4dV1djrlBYP6eBuQZiWjuHUpqFw== -"@types/node@^12.11.1", "@types/node@^12.12.29": - version "12.20.12" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.12.tgz#fd9c1c2cfab536a2383ed1ef70f94adea743a226" - integrity sha512-KQZ1al2hKOONAs2MFv+yTQP1LkDWMrRJ9YCVRalXltOfXsBmH5IownLxQaiq0lnAHwAViLnh2aTYqrPcRGEbgg== - "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" @@ -10817,7 +10817,7 @@ ansi-regex@^3.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= -ansi-regex@^4.0.0, ansi-regex@^4.1.0: +ansi-regex@^4.1.0: version "4.1.1" resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== @@ -14123,7 +14123,7 @@ collection-visit@^1.0.0: map-visit "^1.0.0" object-visit "^1.0.0" -color-convert@^1.9.0, color-convert@^1.9.1, color-convert@^1.9.3: +color-convert@^1.9.0, color-convert@^1.9.3: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -14155,7 +14155,7 @@ color-string@1.5.5: color-name "^1.0.0" simple-swizzle "^0.2.2" -color-string@^1.5.4, color-string@^1.6.0: +color-string@^1.6.0: version "1.9.1" resolved "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz#4467f9146f036f855b764dfb5bf8582bf342c7a4" integrity sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg== @@ -32471,7 +32471,7 @@ react-inspector@^5.1.0: is-dom "^1.0.0" prop-types "^15.0.0" -react-is@16.13.1, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.3.2, react-is@^16.7.0, react-is@^16.8.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6: +react-is@16.13.1, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.3.2, react-is@^16.7.0, react-is@^16.8.0, react-is@^16.8.1, react-is@^16.8.6: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== From 3694f710c05dfe9611e0829cf19808dd876577b3 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Tue, 3 May 2022 19:25:20 -0400 Subject: [PATCH 3/9] restore shelljs --- packages/launcher/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/launcher/package.json b/packages/launcher/package.json index 62c48b0b5e4f..6c8340e7c228 100644 --- a/packages/launcher/package.json +++ b/packages/launcher/package.json @@ -27,6 +27,7 @@ "chai-as-promised": "7.1.1", "mocha": "3.5.3", "mock-fs": "5.1.2", + "shelljs": "0.8.5", "sinon": "^10.0.0", "sinon-chai": "3.4.0", "typescript": "^4.2.3" From eea4eb288db3fbcba8e22120437e4244d1c25457 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Tue, 3 May 2022 19:25:29 -0400 Subject: [PATCH 4/9] Revert "upgrade @types/node" This reverts commit 9a38223f3dfeb43d923e6ded36b802de1bdfa865. --- npm/angular/package.json | 2 +- npm/create-cypress-tests/package.json | 2 +- npm/cypress-schematic/package.json | 2 +- npm/cypress-schematic/sandbox/package.json | 2 +- npm/design-system/package.json | 2 +- package.json | 2 +- packages/errors/package.json | 2 +- packages/runner-ct/package.json | 2 +- packages/server/package.json | 2 +- yarn.lock | 34 +++++++++++----------- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/npm/angular/package.json b/npm/angular/package.json index d47a21dbd2d9..ac8e63ff17e8 100644 --- a/npm/angular/package.json +++ b/npm/angular/package.json @@ -40,7 +40,7 @@ "@cypress/webpack-dev-server": "0.0.0-development", "@cypress/webpack-preprocessor": "5.7.0", "@types/cypress-image-snapshot": "3.1.5", - "@types/node": "16.11.7", + "@types/node": "8.10.66", "angular-router-loader": "0.8.5", "angular2-template-loader": "0.6.2", "codelyzer": "6.0.2", diff --git a/npm/create-cypress-tests/package.json b/npm/create-cypress-tests/package.json index 63a8077660f4..dda6627a31f3 100644 --- a/npm/create-cypress-tests/package.json +++ b/npm/create-cypress-tests/package.json @@ -32,7 +32,7 @@ "@types/babel__core": "^7.1.2", "@types/inquirer": "7.3.1", "@types/mock-fs": "4.10.0", - "@types/node": "16.11.7", + "@types/node": "14.14.31", "@types/ora": "^3.2.0", "copy": "0.3.2", "mocha": "7.1.1", diff --git a/npm/cypress-schematic/package.json b/npm/cypress-schematic/package.json index 24032879b8e2..75068019a7b7 100644 --- a/npm/cypress-schematic/package.json +++ b/npm/cypress-schematic/package.json @@ -30,7 +30,7 @@ "@angular/cli": "^12", "@types/chai-enzyme": "0.6.7", "@types/mocha": "8.0.3", - "@types/node": "16.11.7", + "@types/node": "^12.11.1", "chai": "4.2.0", "cypress": "0.0.0-development", "mocha": "3.5.3", diff --git a/npm/cypress-schematic/sandbox/package.json b/npm/cypress-schematic/sandbox/package.json index b78f08f4fd61..97dd845d8b85 100644 --- a/npm/cypress-schematic/sandbox/package.json +++ b/npm/cypress-schematic/sandbox/package.json @@ -27,7 +27,7 @@ "@angular/cli": "~12.0.0", "@angular/compiler-cli": "~12.0.0", "@types/jasmine": "~3.6.0", - "@types/node": "16.11.7", + "@types/node": "^12.11.1", "jasmine-core": "~3.7.0", "karma": "~6.3.0", "karma-chrome-launcher": "~3.1.0", diff --git a/npm/design-system/package.json b/npm/design-system/package.json index 68092324100a..99c9d353786f 100644 --- a/npm/design-system/package.json +++ b/npm/design-system/package.json @@ -56,7 +56,7 @@ "@storybook/preset-typescript": "^3.0.0", "@storybook/react": "^6.1.21", "@storybook/testing-react": "^0.0.12", - "@types/node": "16.11.7", + "@types/node": "14.14.31", "@types/react-virtualized-auto-sizer": "^1.0.0", "@types/react-window": "^1.8.2", "@types/semver": "7.3.4", diff --git a/package.json b/package.json index 2d8f3e369879..6080eed75bc3 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "@types/markdown-it": "0.0.9", "@types/mini-css-extract-plugin": "1.2.3", "@types/mocha": "8.0.3", - "@types/node": "16.11.7", + "@types/node": "14.14.31", "@types/prismjs": "1.16.0", "@types/react": "16.9.50", "@types/react-dom": "16.9.8", diff --git a/packages/errors/package.json b/packages/errors/package.json index e50e6558664e..d6909490b2ea 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -24,7 +24,7 @@ "@packages/ts": "0.0.0-development", "@types/chai": "4.2.15", "@types/mocha": "8.2.2", - "@types/node": "16.11.7", + "@types/node": "14.14.31", "@types/pngjs": "^6.0.1", "@types/strip-ansi": "^5.2.1", "ansi-styles": "^5", diff --git a/packages/runner-ct/package.json b/packages/runner-ct/package.json index ab6507a7b96f..d141eb17e82f 100644 --- a/packages/runner-ct/package.json +++ b/packages/runner-ct/package.json @@ -24,7 +24,7 @@ "@fortawesome/react-fontawesome": "^0.1.14", "@packages/driver": "0.0.0-development", "@types/http-proxy": "1.17.4", - "@types/node": "16.11.7", + "@types/node": "14.14.31", "@types/sockjs-client": "1.1.0", "babel-loader": "8.1.0", "bluebird": "3.5.3", diff --git a/packages/server/package.json b/packages/server/package.json index b937f305a123..f253231ad479 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -142,7 +142,7 @@ "@types/chai-as-promised": "7.1.2", "@types/chrome": "0.0.101", "@types/http-proxy": "1.17.4", - "@types/node": "16.11.7", + "@types/node": "14.14.31", "babel-loader": "8.1.0", "chai-as-promised": "7.1.1", "chai-subset": "1.6.0", diff --git a/yarn.lock b/yarn.lock index 185224a3e290..cb4d9c030e71 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4138,9 +4138,9 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^13.0.0" -"@jest/types@^26.3.0", "@jest/types@^26.6.2": +"@jest/types@^26.6.2": version "26.6.2" - resolved "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" integrity sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ== dependencies: "@types/istanbul-lib-coverage" "^2.0.0" @@ -8717,26 +8717,26 @@ "@types/node" "*" form-data "^3.0.0" -"@types/node@*", "@types/node@16.11.7", "@types/node@>= 8", "@types/node@>=10.0.0": - version "16.11.7" - resolved "https://registry.npmjs.org/@types/node/-/node-16.11.7.tgz#36820945061326978c42a01e56b61cd223dfdc42" - integrity sha512-QB5D2sqfSjCmTuWcBWyJ+/44bcjO7VbjSbOE0ucoVbAsSNQc4Lt6QkgkVXkTDwkL4z/beecZNDvVX15D4P8Jbw== - -"@types/node@^12.12.29": - version "12.20.12" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.12.tgz#fd9c1c2cfab536a2383ed1ef70f94adea743a226" - integrity sha512-KQZ1al2hKOONAs2MFv+yTQP1LkDWMrRJ9YCVRalXltOfXsBmH5IownLxQaiq0lnAHwAViLnh2aTYqrPcRGEbgg== +"@types/node@*", "@types/node@>= 8", "@types/node@>=10.0.0": + version "15.0.1" + resolved "https://registry.npmjs.org/@types/node/-/node-15.0.1.tgz#ef34dea0881028d11398be5bf4e856743e3dc35a" + integrity sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA== -"@types/node@^14.0.10", "@types/node@^14.14.31", "@types/node@^14.6.2": +"@types/node@14.14.31", "@types/node@^14.0.10", "@types/node@^14.14.31", "@types/node@^14.6.2": version "14.14.31" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.31.tgz#72286bd33d137aa0d152d47ec7c1762563d34055" integrity sha512-vFHy/ezP5qI0rFgJ7aQnjDXwAMrG0KqqIH7tQG5PPv3BWBayOPIQNBjVc/P6hhdZfMx51REc6tfDNXHUio893g== -"@types/node@^8.0.7": +"@types/node@8.10.66", "@types/node@^8.0.7": version "8.10.66" resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.66.tgz#dd035d409df322acc83dff62a602f12a5783bbb3" integrity sha512-tktOkFUA4kXx2hhhrB8bIFb5TbwzS4uOhKEmwiD+NoiL0qtP2OQ9mFldbgD4dV1djrlBYP6eBuQZiWjuHUpqFw== +"@types/node@^12.11.1", "@types/node@^12.12.29": + version "12.20.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.12.tgz#fd9c1c2cfab536a2383ed1ef70f94adea743a226" + integrity sha512-KQZ1al2hKOONAs2MFv+yTQP1LkDWMrRJ9YCVRalXltOfXsBmH5IownLxQaiq0lnAHwAViLnh2aTYqrPcRGEbgg== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" @@ -10817,7 +10817,7 @@ ansi-regex@^3.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= -ansi-regex@^4.1.0: +ansi-regex@^4.0.0, ansi-regex@^4.1.0: version "4.1.1" resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== @@ -14123,7 +14123,7 @@ collection-visit@^1.0.0: map-visit "^1.0.0" object-visit "^1.0.0" -color-convert@^1.9.0, color-convert@^1.9.3: +color-convert@^1.9.0, color-convert@^1.9.1, color-convert@^1.9.3: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -14155,7 +14155,7 @@ color-string@1.5.5: color-name "^1.0.0" simple-swizzle "^0.2.2" -color-string@^1.6.0: +color-string@^1.5.4, color-string@^1.6.0: version "1.9.1" resolved "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz#4467f9146f036f855b764dfb5bf8582bf342c7a4" integrity sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg== @@ -32471,7 +32471,7 @@ react-inspector@^5.1.0: is-dom "^1.0.0" prop-types "^15.0.0" -react-is@16.13.1, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.3.2, react-is@^16.7.0, react-is@^16.8.0, react-is@^16.8.1, react-is@^16.8.6: +react-is@16.13.1, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.3.2, react-is@^16.7.0, react-is@^16.8.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== From cbda09aca5ef5ff31e29804f7374d4f145d36dfe Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Tue, 3 May 2022 19:28:37 -0400 Subject: [PATCH 5/9] ts ignore fs.read --- packages/launcher/lib/linux/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/launcher/lib/linux/index.ts b/packages/launcher/lib/linux/index.ts index c16b7177c7c5..ba970aa16a27 100644 --- a/packages/launcher/lib/linux/index.ts +++ b/packages/launcher/lib/linux/index.ts @@ -14,7 +14,8 @@ async function isFirefoxSnap (binary: string): Promise { // read the first 16kb, don't read the entire file into memory in case it is a binary const fd = await fs.open(binaryPath, 'r') - const { buffer, bytesRead } = await fd.read({ length: 16384 }) + // @ts-ignore - needs @types/node at least 16 + const { buffer, bytesRead } = await fd.read({ length: 16384 }) fd.close() From 918042ee8fba873e7e561b39b1a9a01f5f27e3c7 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Tue, 3 May 2022 19:42:26 -0400 Subject: [PATCH 6/9] minimize yarn.lock diff --- yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index cb4d9c030e71..ab972e1c01ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4138,9 +4138,9 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^13.0.0" -"@jest/types@^26.6.2": +"@jest/types@^26.3.0", "@jest/types@^26.6.2": version "26.6.2" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" + resolved "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" integrity sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ== dependencies: "@types/istanbul-lib-coverage" "^2.0.0" @@ -10817,7 +10817,7 @@ ansi-regex@^3.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= -ansi-regex@^4.0.0, ansi-regex@^4.1.0: +ansi-regex@^4.1.0: version "4.1.1" resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== @@ -14123,7 +14123,7 @@ collection-visit@^1.0.0: map-visit "^1.0.0" object-visit "^1.0.0" -color-convert@^1.9.0, color-convert@^1.9.1, color-convert@^1.9.3: +color-convert@^1.9.0, color-convert@^1.9.3: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -14155,7 +14155,7 @@ color-string@1.5.5: color-name "^1.0.0" simple-swizzle "^0.2.2" -color-string@^1.5.4, color-string@^1.6.0: +color-string@^1.6.0: version "1.9.1" resolved "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz#4467f9146f036f855b764dfb5bf8582bf342c7a4" integrity sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg== @@ -32471,7 +32471,7 @@ react-inspector@^5.1.0: is-dom "^1.0.0" prop-types "^15.0.0" -react-is@16.13.1, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.3.2, react-is@^16.7.0, react-is@^16.8.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6: +react-is@16.13.1, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.3.2, react-is@^16.7.0, react-is@^16.8.0, react-is@^16.8.1, react-is@^16.8.6: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== From 5e832925e85cf54fccf0fccec34677a5aa9c780b Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Tue, 3 May 2022 20:35:40 -0400 Subject: [PATCH 7/9] add timeout and comment --- packages/launcher/lib/linux/index.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/launcher/lib/linux/index.ts b/packages/launcher/lib/linux/index.ts index ba970aa16a27..2bcc3dc9a124 100644 --- a/packages/launcher/lib/linux/index.ts +++ b/packages/launcher/lib/linux/index.ts @@ -10,16 +10,20 @@ import which from 'which' async function isFirefoxSnap (binary: string): Promise { try { - const binaryPath = await which(binary) + return Bluebird.resolve((async () => { + const binaryPath = await which(binary) - // read the first 16kb, don't read the entire file into memory in case it is a binary - const fd = await fs.open(binaryPath, 'r') - // @ts-ignore - needs @types/node at least 16 - const { buffer, bytesRead } = await fd.read({ length: 16384 }) + // read the first 16kb, don't read the entire file into memory in case it is a binary + const fd = await fs.open(binaryPath, 'r') + // @ts-ignore - needs @types/node at least 16 + // https://github.com/cypress-io/cypress/issues/21329 + const { buffer, bytesRead } = await fd.read({ length: 16384 }) - fd.close() + await fd.close() - return buffer.slice(0, bytesRead).toString('utf8').includes('exec /snap/bin/firefox') + return buffer.slice(0, bytesRead).toString('utf8').includes('exec /snap/bin/firefox') + })()) + .timeout(30000) } catch (err) { log('failed to check if Firefox is a snap, assuming it isn\'t %o', { err, binary }) From a81493d27edb1cf39de79de3e39f8aabd22cf827 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Tue, 3 May 2022 20:36:20 -0400 Subject: [PATCH 8/9] catch timeout --- packages/launcher/lib/linux/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/launcher/lib/linux/index.ts b/packages/launcher/lib/linux/index.ts index 2bcc3dc9a124..c46c78412f94 100644 --- a/packages/launcher/lib/linux/index.ts +++ b/packages/launcher/lib/linux/index.ts @@ -10,7 +10,7 @@ import which from 'which' async function isFirefoxSnap (binary: string): Promise { try { - return Bluebird.resolve((async () => { + return await Bluebird.resolve((async () => { const binaryPath = await which(binary) // read the first 16kb, don't read the entire file into memory in case it is a binary From 4d8aae37fbf0cd28733d201ebd166e3a30179ec6 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Thu, 5 May 2022 11:42:21 -0400 Subject: [PATCH 9/9] detect firefox via path too --- packages/launcher/lib/linux/index.ts | 3 ++ packages/launcher/test/unit/linux_spec.ts | 59 +++++++++++++++++------ 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/packages/launcher/lib/linux/index.ts b/packages/launcher/lib/linux/index.ts index c46c78412f94..d8b0410fba71 100644 --- a/packages/launcher/lib/linux/index.ts +++ b/packages/launcher/lib/linux/index.ts @@ -13,6 +13,9 @@ async function isFirefoxSnap (binary: string): Promise { return await Bluebird.resolve((async () => { const binaryPath = await which(binary) + // if the bin path or what it's symlinked to start with `/snap/bin`, it's a snap + if (binaryPath.startsWith('/snap/bin/') || (await fs.realpath(binaryPath)).startsWith('/snap/bin')) return true + // read the first 16kb, don't read the entire file into memory in case it is a binary const fd = await fs.open(binaryPath, 'r') // @ts-ignore - needs @types/node at least 16 diff --git a/packages/launcher/test/unit/linux_spec.ts b/packages/launcher/test/unit/linux_spec.ts index 2631306cd7d6..9170defa427f 100644 --- a/packages/launcher/test/unit/linux_spec.ts +++ b/packages/launcher/test/unit/linux_spec.ts @@ -80,21 +80,8 @@ describe('linux browser detection', () => { }) // https://github.com/cypress-io/cypress/issues/19793 - it('sets profilePath on snapcraft firefox', async () => { - process.env.PATH = '/bin' - mockFs({ - '/bin/firefox': mockFs.symlink({ path: '/usr/bin/firefox' }), - '/usr/bin/firefox': mockFs.file({ mode: 0o777, content: 'foo bar foo bar foo bar\nexec /snap/bin/firefox\n' }), - }) - - execa.withArgs('firefox', ['--version']) - .resolves({ stdout: 'Mozilla Firefox 99.2.3' }) - - sinon.stub(os, 'homedir').returns('/home/foo') - - const [browser] = await detect() - - expect(browser).to.deep.equal({ + context('sets profilePath on snapcraft firefox', () => { + const expectedSnapFirefox = { channel: 'stable', name: 'firefox', family: 'firefox', @@ -104,6 +91,48 @@ describe('linux browser detection', () => { path: 'firefox', profilePath: '/home/foo/snap/firefox/current', version: '99.2.3', + } + + beforeEach(() => { + execa.withArgs('firefox', ['--version']) + .resolves({ stdout: 'Mozilla Firefox 99.2.3' }) + + sinon.stub(os, 'homedir').returns('/home/foo') + }) + + it('with shim script', async () => { + process.env.PATH = '/bin' + mockFs({ + '/bin/firefox': mockFs.symlink({ path: '/usr/bin/firefox' }), + '/usr/bin/firefox': mockFs.file({ mode: 0o777, content: 'foo bar foo bar foo bar\nexec /snap/bin/firefox\n' }), + }) + + const [browser] = await detect() + + expect(browser).to.deep.equal(expectedSnapFirefox) + }) + + it('with /snap/bin in path', async () => { + process.env.PATH = '/bin:/snap/bin' + mockFs({ + '/snap/bin/firefox': mockFs.file({ mode: 0o777, content: 'binary' }), + }) + + const [browser] = await detect() + + expect(browser).to.deep.equal(expectedSnapFirefox) + }) + + it('with symlink to /snap/bin in path', async () => { + process.env.PATH = '/bin' + mockFs({ + '/bin/firefox': mockFs.symlink({ path: '/snap/bin/firefox' }), + '/snap/bin/firefox': mockFs.file({ mode: 0o777, content: 'binary' }), + }) + + const [browser] = await detect() + + expect(browser).to.deep.equal(expectedSnapFirefox) }) })