From 223cd35db83e88552e02d626ec3954bce80d4645 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Fri, 10 May 2024 17:53:44 -0400 Subject: [PATCH] chore: remove opn dep (#29504) * chore: remove opn dep * empty commit --- packages/server/lib/gui/menu.js | 5 +- packages/server/lib/socket-base.ts | 8 --- packages/server/lib/util/open.js | 13 ---- packages/server/package.json | 1 - packages/server/test/unit/gui/menu_spec.js | 5 +- packages/server/test/unit/util/open_spec.js | 48 -------------- yarn.lock | 70 ++------------------- 7 files changed, 8 insertions(+), 142 deletions(-) delete mode 100644 packages/server/lib/util/open.js delete mode 100644 packages/server/test/unit/util/open_spec.js diff --git a/packages/server/lib/gui/menu.js b/packages/server/lib/gui/menu.js index 9f95518656d5..0bd1e987d610 100644 --- a/packages/server/lib/gui/menu.js +++ b/packages/server/lib/gui/menu.js @@ -4,7 +4,6 @@ const { Menu } = require('electron') const { shell } = require('electron') const appData = require('../util/app_data') -const open = require('../util/open') // hoist up options and allow calling menu.set({}) // to override existing options or be called multiple @@ -44,7 +43,7 @@ module.exports = { { label: 'View App Data', click () { - return open.opn(appData.path()) + return shell.openPath(appData.path()) }, }, { @@ -195,7 +194,7 @@ module.exports = { { label: 'View App Data', click () { - return open.opn(appData.path()) + return shell.openPath(appData.path()) }, }, ] diff --git a/packages/server/lib/socket-base.ts b/packages/server/lib/socket-base.ts index 142c1b30a6a4..475da05c4334 100644 --- a/packages/server/lib/socket-base.ts +++ b/packages/server/lib/socket-base.ts @@ -14,7 +14,6 @@ import fixture from './fixture' import { ensureProp } from './util/class-helpers' import { getUserEditor, setUserEditor } from './util/editors' import { openFile, OpenFileDetails } from './util/file-opener' -import open from './util/open' import type { DestroyableHttpServer } from './util/server_destroy' import * as session from './session' import { cookieJar, SameSiteContext, automationCookieToToughCookie, SerializableAutomationCookie } from './util/cookies' @@ -338,13 +337,6 @@ export class SocketBase { return options.onMocha.apply(options, args) }) - socket.on('open:finder', (p, cb = function () {}) => { - return open.opn(p) - .then(() => { - return cb() - }) - }) - socket.on('recorder:frame', (data) => { return options.onCaptureVideoFrames(data) }) diff --git a/packages/server/lib/util/open.js b/packages/server/lib/util/open.js deleted file mode 100644 index 2a1f6b8555b6..000000000000 --- a/packages/server/lib/util/open.js +++ /dev/null @@ -1,13 +0,0 @@ -// wrapper around opn due to issues with proxyquire + istanbul -const os = require('os') -const opn = require('opn') - -module.exports = { - opn (arg, opts = {}) { - if (os.platform() === 'darwin') { - opts.args = '-R' - } - - return opn(arg, opts) - }, -} diff --git a/packages/server/package.json b/packages/server/package.json index a746e12c01d0..e42d9ec32361 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -101,7 +101,6 @@ "mocha-teamcity-reporter": "3.0.0", "morgan": "1.9.1", "node-machine-id": "1.1.12", - "opn": "https://github.com/cypress-io/opn.git#2f4e9a216ca7bdb95dfae9d46d99ddf004b3cbb5", "ospath": "1.2.2", "p-defer": "^3.0.0", "p-queue": "6.1.0", diff --git a/packages/server/test/unit/gui/menu_spec.js b/packages/server/test/unit/gui/menu_spec.js index 95aaab5017b8..40fda52b68cb 100644 --- a/packages/server/test/unit/gui/menu_spec.js +++ b/packages/server/test/unit/gui/menu_spec.js @@ -4,7 +4,6 @@ const _ = require('lodash') const os = require('os') const electron = require('electron') const appData = require(`../../../lib/util/app_data`) -const open = require(`../../../lib/util/open`) const menu = require(`../../../lib/gui/menu`) const getMenuItem = function (label) { @@ -25,6 +24,7 @@ describe('gui/menu', function () { sinon.stub(electron.Menu, 'buildFromTemplate') sinon.stub(electron.Menu, 'setApplicationMenu') electron.shell.openExternal = sinon.stub() + electron.shell.openPath = sinon.stub() }) it('builds menu from template and sets it', () => { @@ -77,10 +77,9 @@ describe('gui/menu', function () { }) it('opens app data directory when View App Data is clicked', () => { - sinon.stub(open, 'opn') menu.set() getSubMenuItem(getMenuItem('File'), 'View App Data').click() - expect(open.opn).to.be.calledWith(appData.path()) + expect(electron.shell.openPath).to.be.calledWith(appData.path()) }) it('calls logout callback when Log Out is clicked', () => { diff --git a/packages/server/test/unit/util/open_spec.js b/packages/server/test/unit/util/open_spec.js deleted file mode 100644 index 3160e512f1c5..000000000000 --- a/packages/server/test/unit/util/open_spec.js +++ /dev/null @@ -1,48 +0,0 @@ -require('../../spec_helper') - -const cp = require('child_process') -const open = require(`../../../lib/util/open`) - -const platform = (p) => { - return Object.defineProperty(process, 'platform', { - value: p, - }) -} - -describe('lib/util/open', () => { - beforeEach(function () { - this.platform = process.platform - - const cpStub = sinon.stub({ - once () {}, - unref () {}, - }) - - cpStub.once.withArgs('close').yieldsAsync(0) - - return sinon.stub(cp, 'spawn').returns(cpStub) - }) - - afterEach(function () { - // reset the platform - return platform(this.platform) - }) - - it('spawns process with osx args', () => { - platform('darwin') - - return open.opn('../foo', { args: '-R' }) - .then(() => { - expect(cp.spawn).to.be.calledWith('open', ['-W', '-R', '../foo']) - }) - }) - - it('spawns process with linux args', () => { - platform('linux') - - return open.opn('../foo', { args: '-R' }) - .then(() => { - expect(cp.spawn).to.be.calledWithMatch('xdg-open', ['../foo']) - }) - }) -}) diff --git a/yarn.lock b/yarn.lock index 8f7cb1bbd1ba..bba055b86c0c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22102,7 +22102,7 @@ mobx@5.15.4: resolved "https://registry.yarnpkg.com/mobx/-/mobx-5.15.4.tgz#9da1a84e97ba624622f4e55a0bf3300fb931c2ab" integrity sha512-xRFJxSU2Im3nrGCdjSuOTFmxVDGeqOHL+TyADCGbT0k4HHqGmx5u2yaHNryvoORpI4DfbzjJ5jPmuv+d7sioFw== -"mocha-7.0.1@npm:mocha@7.0.1": +"mocha-7.0.1@npm:mocha@7.0.1", mocha@7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.0.1.tgz#276186d35a4852f6249808c6dd4a1376cbf6c6ce" integrity sha512-9eWmWTdHLXh72rGrdZjNbG3aa1/3NRPpul1z0D979QpEnFdCG0Q5tv834N+94QEN2cysfV72YocQ3fn87s70fg== @@ -22235,36 +22235,6 @@ mocha@6.2.2: yargs-parser "13.1.1" yargs-unparser "1.6.0" -mocha@7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.0.1.tgz#276186d35a4852f6249808c6dd4a1376cbf6c6ce" - integrity sha512-9eWmWTdHLXh72rGrdZjNbG3aa1/3NRPpul1z0D979QpEnFdCG0Q5tv834N+94QEN2cysfV72YocQ3fn87s70fg== - dependencies: - ansi-colors "3.2.3" - browser-stdout "1.3.1" - chokidar "3.3.0" - debug "3.2.6" - diff "3.5.0" - escape-string-regexp "1.0.5" - find-up "3.0.0" - glob "7.1.3" - growl "1.10.5" - he "1.2.0" - js-yaml "3.13.1" - log-symbols "2.2.0" - minimatch "3.0.4" - mkdirp "0.5.1" - ms "2.1.1" - node-environment-flags "1.0.6" - object.assign "4.1.0" - strip-json-comments "2.0.1" - supports-color "6.0.0" - which "1.3.1" - wide-align "1.1.3" - yargs "13.3.0" - yargs-parser "13.1.1" - yargs-unparser "1.6.0" - mocha@7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.1.0.tgz#c784f579ad0904d29229ad6cb1e2514e4db7d249" @@ -23992,13 +23962,6 @@ opn@^5.5.0: dependencies: is-wsl "^1.1.0" -"opn@https://github.com/cypress-io/opn.git#2f4e9a216ca7bdb95dfae9d46d99ddf004b3cbb5": - version "4.0.1" - resolved "https://github.com/cypress-io/opn.git#2f4e9a216ca7bdb95dfae9d46d99ddf004b3cbb5" - dependencies: - object-assign "^4.0.1" - pinkie-promise "^2.0.0" - optimist@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" @@ -28901,7 +28864,7 @@ string-template@~0.2.1: resolved "https://registry.yarnpkg.com/string-template/-/string-template-0.2.1.tgz#42932e598a352d01fc22ec3367d9d84eec6c9add" integrity sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0= -"string-width-cjs@npm:string-width@^4.2.0": +"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -28927,15 +28890,6 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - string-width@^3.0.0, string-width@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" @@ -29037,7 +28991,7 @@ stringify-object@^3.0.0, stringify-object@^3.3.0: is-obj "^1.0.1" is-regexp "^1.0.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -29079,13 +29033,6 @@ strip-ansi@^3.0.0, strip-ansi@^3.0.1: dependencies: ansi-regex "^2.0.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.1.1.tgz#39e8a98d044d150660abe4a6808acf70bb7bc991" @@ -32125,7 +32072,7 @@ workerpool@6.2.0: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.0.tgz#827d93c9ba23ee2019c3ffaff5c27fccea289e8b" integrity sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -32168,15 +32115,6 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.0.1, wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"