Files
cypress/cli/lib/exec/versions.ts
Bill Glesias 31ee30b6f3 chore: convert CLI tests to vitest (#32416)
* chore: rename snapshots and spec files to fit vitest convention (#32405)

* chore: move compiled files to dist directory to make vitest convertion easier (#32406)

* chore: convert utils to vitest (#32407)

* chore: convert logger to vitest

* chore: convert errors spec to vitest

* chore: convert cypress spec to vitest

* chore: convert `exec` directory to `vitest` (#32428)

* chore: cut over exec directory to vitest

* Update cli/test/lib/exec/run.spec.ts

* Update cli/test/lib/exec/run.spec.ts

* Update cli/test/lib/exec/run.spec.ts

* chore: convert the CLI and build script specs over to vitest (#32438)

* chore: convert tasks directory to vitest (#32434)

change way verify module is exported due to issues interpreting module (thinks its an esm)

rework scripts as we cannot run an empty mocha suite

chore: fix snapshots and verify requires that are internal to the cypress project

fix stubbing issues with fs-extra which is also used by request-progress under the hood

fix issues where xvfb was stopping prematurely

* chore: remove files no longer used now that mocha tests are converted to vitest (#32455)

* build binaries

* chore: fix CLI tests (#32484)

* chore: remove CI branch
2025-09-12 19:20:13 -04:00

72 lines
1.9 KiB
TypeScript

import Debug from 'debug'
import path from 'path'
import util from '../util'
import state from '../tasks/state'
import { throwFormErrorText, errors } from '../errors'
const debug = Debug('cypress:cli')
const getBinaryDirectory = async (): Promise<string> => {
if (util.getEnv('CYPRESS_RUN_BINARY')) {
let envBinaryPath = path.resolve(util.getEnv('CYPRESS_RUN_BINARY') as string)
try {
const envBinaryDir = await state.parseRealPlatformBinaryFolderAsync(envBinaryPath)
if (!envBinaryDir) {
const raiseErrorFn = throwFormErrorText(errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))
await raiseErrorFn()
}
debug('CYPRESS_RUN_BINARY has binaryDir:', envBinaryDir)
return envBinaryDir
} catch (err: any) {
const raiseErrorFn = throwFormErrorText(errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))
await raiseErrorFn(err.message)
}
}
return state.getBinaryDir()
}
const getVersions = async (): Promise<any> => {
const binDir = await getBinaryDirectory()
const pkg = await state.getBinaryPkgAsync(binDir)
const versions = {
binary: state.getBinaryPkgVersion(pkg),
electronVersion: state.getBinaryElectronVersion(pkg),
electronNodeVersion: state.getBinaryElectronNodeVersion(pkg),
}
debug('binary versions %o', versions)
const buildInfo = util.pkgBuildInfo()
let packageVersion = util.pkgVersion()
if (!buildInfo) packageVersion += ' (development)'
else if (!buildInfo.stable) packageVersion += ' (pre-release)'
const versionsFinal = {
package: packageVersion,
binary: versions.binary || 'not installed',
electronVersion: versions.electronVersion || 'not found',
electronNodeVersion: versions.electronNodeVersion || 'not found',
}
debug('combined versions %o', versions)
return versionsFinal
}
const versionsModule = {
getVersions,
}
export default versionsModule