diff --git a/.circleci/cache-version.txt b/.circleci/cache-version.txt index fc3ae1411bde..ac501d1253cf 100644 --- a/.circleci/cache-version.txt +++ b/.circleci/cache-version.txt @@ -1,3 +1,3 @@ # Bump this version to force CI to re-create the cache from scratch. -12-01-22 +12-05-22 diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index e83ed010ca83..5f6185bcea4d 100644 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -29,7 +29,6 @@ mainBuildFilters: &mainBuildFilters - develop - /^release\/\d+\.\d+\.\d+$/ - 'ryanm/fix/issue-with-integrity-check' - - 'mschile/windows_session' # usually we don't build Mac app - it takes a long time # but sometimes we want to really confirm we are doing the right thing @@ -39,7 +38,6 @@ macWorkflowFilters: &darwin-workflow-filters or: - equal: [ develop, << pipeline.git.branch >> ] - equal: [ 'ryanm/fix/issue-with-integrity-check', << pipeline.git.branch >> ] - - equal: [ 'mschile/windows_session', << pipeline.git.branch >> ] - matches: pattern: /^release\/\d+\.\d+\.\d+$/ value: << pipeline.git.branch >> @@ -48,7 +46,6 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters or: - equal: [ develop, << pipeline.git.branch >> ] - equal: [ 'ryanm/fix/issue-with-integrity-check', << pipeline.git.branch >> ] - - equal: [ 'mschile/windows_session', << pipeline.git.branch >> ] - matches: pattern: /^release\/\d+\.\d+\.\d+$/ value: << pipeline.git.branch >> @@ -67,7 +64,6 @@ windowsWorkflowFilters: &windows-workflow-filters or: - equal: [ develop, << pipeline.git.branch >> ] - equal: [ 'ryanm/fix/issue-with-integrity-check', << pipeline.git.branch >> ] - - equal: [ 'mschile/windows_session', << pipeline.git.branch >> ] - matches: pattern: /^release\/\d+\.\d+\.\d+$/ value: << pipeline.git.branch >> diff --git a/npm/vite-dev-server/cypress.config.ts b/npm/vite-dev-server/cypress.config.ts index 335561f589b9..cebb4a8d5d55 100644 --- a/npm/vite-dev-server/cypress.config.ts +++ b/npm/vite-dev-server/cypress.config.ts @@ -11,6 +11,7 @@ export default defineConfig({ // Delete this as we only want to honor it on parent Cypress when doing E2E Cypress in Cypress testing delete process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS + delete process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF = 'true' process.env.CYPRESS_INTERNAL_VITE_OPEN_MODE_TESTING = 'true' const { e2ePluginSetup } = require('@packages/frontend-shared/cypress/e2e/e2ePluginSetup') as typeof import('@packages/frontend-shared/cypress/e2e/e2ePluginSetup') diff --git a/npm/vite-dev-server/package.json b/npm/vite-dev-server/package.json index 0a431ff76921..ff12f0021eab 100644 --- a/npm/vite-dev-server/package.json +++ b/npm/vite-dev-server/package.json @@ -8,7 +8,7 @@ "build-prod": "tsc || echo 'built, with type errors'", "check-ts": "tsc --noEmit", "cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome", - "cypress:run-cypress-in-cypress": "cross-env HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", + "cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", "cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", "watch": "tsc -w", "test": "yarn test-unit", diff --git a/npm/webpack-dev-server/cypress.config.ts b/npm/webpack-dev-server/cypress.config.ts index 3f0809d05ca5..204d392c906d 100644 --- a/npm/webpack-dev-server/cypress.config.ts +++ b/npm/webpack-dev-server/cypress.config.ts @@ -11,6 +11,7 @@ export default defineConfig({ // Delete this as we only want to honor it on parent Cypress when doing E2E Cypress in Cypress testing delete process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS + delete process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF = 'true' const { e2ePluginSetup } = require('@packages/frontend-shared/cypress/e2e/e2ePluginSetup') as typeof import('@packages/frontend-shared/cypress/e2e/e2ePluginSetup') diff --git a/npm/webpack-dev-server/package.json b/npm/webpack-dev-server/package.json index 1a6deced9929..e753aaa814bb 100644 --- a/npm/webpack-dev-server/package.json +++ b/npm/webpack-dev-server/package.json @@ -11,7 +11,7 @@ "dev": "tsc --watch", "clean": "rimraf dist", "cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome", - "cypress:run-cypress-in-cypress": "cross-env HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", + "cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", "cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", "test": "yarn test-unit", "test-unit": "mocha -r ts-node/register/transpile-only --config ./test/.mocharc.js", diff --git a/package.json b/package.json index 9597366832df..f5474005dc6f 100644 --- a/package.json +++ b/package.json @@ -69,10 +69,6 @@ "watch": "yarn gulp watch", "prepare": "husky install" }, - "dependencies": { - "bytenode": "1.3.7", - "nvm": "0.0.4" - }, "devDependencies": { "@aws-sdk/credential-providers": "3.53.0", "@cypress/questions-remain": "1.0.1", @@ -132,6 +128,7 @@ "babel-eslint": "10.1.0", "bluebird": "3.5.3", "bluebird-retry": "0.11.0", + "bytenode": "1.3.7", "c8": "^7.10.0", "chai": "4.2.0", "chai-as-promised": "7.1.1", diff --git a/packages/app/cypress.config.ts b/packages/app/cypress.config.ts index b68bd988a6dc..12a2dc92ed83 100644 --- a/packages/app/cypress.config.ts +++ b/packages/app/cypress.config.ts @@ -35,6 +35,7 @@ export default defineConfig({ // Delete this as we only want to honor it on parent Cypress when doing E2E Cypress in Cypress testing delete process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS + delete process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF = 'true' process.env.CYPRESS_INTERNAL_VITE_OPEN_MODE_TESTING = 'true' // process.env.DEBUG = '*' diff --git a/packages/app/cypress/e2e/runs.cy.ts b/packages/app/cypress/e2e/runs.cy.ts index 9c9958eca317..4657f0953105 100644 --- a/packages/app/cypress/e2e/runs.cy.ts +++ b/packages/app/cypress/e2e/runs.cy.ts @@ -77,7 +77,7 @@ describe('App: Runs', { viewportWidth: 1200 }, () => { moveToRunsPage() cy.contains(defaultMessages.runs.connect.buttonUser).click() cy.withCtx((ctx, o) => { - o.sinon.spy(ctx._apis.authApi, 'logIn') + o.sinon.stub(ctx._apis.authApi, 'logIn') }) cy.findByRole('dialog', { name: 'Log in to Cypress' }).within(() => { diff --git a/packages/app/cypress/e2e/settings.cy.ts b/packages/app/cypress/e2e/settings.cy.ts index d286613373d2..d49f3c8408be 100644 --- a/packages/app/cypress/e2e/settings.cy.ts +++ b/packages/app/cypress/e2e/settings.cy.ts @@ -399,7 +399,7 @@ describe('App: Settings without cloud', () => { cy.findByText('Cypress Cloud settings').click() cy.findByText('Project ID').should('not.exist') cy.withCtx((ctx, o) => { - o.sinon.spy(ctx._apis.authApi, 'logIn') + o.sinon.stub(ctx._apis.authApi, 'logIn') }) cy.contains('button', 'Log in to Cypress Cloud').click() diff --git a/packages/app/package.json b/packages/app/package.json index 6cc8d50c3458..5c4babc749b1 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -8,7 +8,7 @@ "clean": "rimraf dist && rimraf ./node_modules/.vite && echo 'cleaned'", "clean-deps": "rimraf node_modules", "test": "echo 'ok'", - "cypress:run-cypress-in-cypress": "cross-env HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", + "cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", "cypress:launch": "yarn cypress:run-cypress-in-cypress gulp open --project .", "cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", "cypress:run:ct": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --component --project .", diff --git a/packages/config/package.json b/packages/config/package.json index 0ed4098d1bab..d9f723ff7b7b 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -21,7 +21,7 @@ "@babel/parser": "^7", "@babel/plugin-syntax-typescript": "^7", "@babel/plugin-transform-typescript": "^7", - "@babel/traverse": "^7", + "@babel/traverse": "7.15.4", "@babel/types": "^7", "check-more-types": "2.24.0", "common-tags": "1.8.0", diff --git a/packages/data-context/src/data/ProjectConfigIpc.ts b/packages/data-context/src/data/ProjectConfigIpc.ts index 5b3e32465c48..bbe7a372d200 100644 --- a/packages/data-context/src/data/ProjectConfigIpc.ts +++ b/packages/data-context/src/data/ProjectConfigIpc.ts @@ -1,7 +1,7 @@ /* eslint-disable no-dupe-class-members */ import { CypressError, getError } from '@packages/errors' import type { FullConfig, TestingType } from '@packages/types' -import { ChildProcess, fork, ForkOptions } from 'child_process' +import { ChildProcess, fork, ForkOptions, spawn } from 'child_process' import EventEmitter from 'events' import fs from 'fs-extra' import path from 'path' @@ -10,6 +10,7 @@ import debugLib from 'debug' import { autoBindDebug, hasTypeScriptInstalled, toPosix } from '../util' import _ from 'lodash' import { pathToFileURL } from 'url' +import os from 'os' const pkg = require('@packages/root') const debug = debugLib(`cypress:lifecycle:ProjectConfigIpc`) @@ -21,6 +22,14 @@ const tsNode = toPosix(require.resolve('@packages/server/lib/plugins/child/regis export type IpcHandler = (ipc: ProjectConfigIpc) => void +/** + * If running as root on Linux, no-sandbox must be passed or Chrome will not start + */ +const isSandboxNeeded = () => { + // eslint-disable-next-line no-restricted-properties + return (os.platform() === 'linux') && (process.geteuid && process.geteuid() === 0) +} + export interface SetupNodeEventsReply { setupConfig: Cypress.ConfigOptions | null requires: string[] @@ -310,6 +319,17 @@ export class ProjectConfigIpc extends EventEmitter { debug(`no typescript found, just use regular Node.js`) } + if (process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT) { + if (isSandboxNeeded()) { + configProcessArgs.push('--no-sandbox') + } + + return spawn(process.execPath, ['--entryPoint', CHILD_PROCESS_FILE_PATH, ...configProcessArgs], { + ...childOptions, + stdio: ['pipe', 'pipe', 'pipe', 'ipc'], + }) + } + return fork(CHILD_PROCESS_FILE_PATH, configProcessArgs, childOptions) } diff --git a/packages/data-context/src/sources/ErrorDataSource.ts b/packages/data-context/src/sources/ErrorDataSource.ts index f116b4083b43..965b84b1534b 100644 --- a/packages/data-context/src/sources/ErrorDataSource.ts +++ b/packages/data-context/src/sources/ErrorDataSource.ts @@ -38,7 +38,7 @@ export class ErrorDataSource { } else { // Skip any stack trace lines which come from node:internal code const stackLines = stackUtils.getStackLines(source.cypressError.stack ?? '') - const filteredStackLines = stackLines.filter((stackLine) => !stackLine.includes('node:internal') && !stackLine.includes('source-map-support')) + const filteredStackLines = stackLines.filter((stackLine) => !stackLine.includes('node:electron') && !stackLine.includes('node:internal') && !stackLine.includes('source-map-support')) const parsedLine = stackUtils.parseStackLine(filteredStackLines[0] ?? '') if (parsedLine) { diff --git a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts index fb8cbb5c8057..09cd4ff25773 100644 --- a/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts +++ b/packages/frontend-shared/cypress/e2e/e2ePluginSetup.ts @@ -1,3 +1,7 @@ +import { hookRequire } from '@packages/server/hook-require' + +hookRequire({ forceTypeScript: false }) + import path from 'path' import execa from 'execa' @@ -43,6 +47,11 @@ chai.use(chaiSubset) chai.use(sinonChai) export async function e2ePluginSetup (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) { + // @ts-ignore snapshotAuxiliaryData is injected by the snapshot script + if (typeof global.snapshotAuxiliaryData === 'undefined') { + throw new Error('snapshotAuxiliaryData is undefined. v8 snapshots are not being used in Cypress in Cypress') + } + process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF = 'true' delete process.env.CYPRESS_INTERNAL_GRAPHQL_PORT delete process.env.CYPRESS_INTERNAL_VITE_DEV diff --git a/packages/launchpad/cypress.config.ts b/packages/launchpad/cypress.config.ts index 83b60d158c03..71ab5456fda9 100644 --- a/packages/launchpad/cypress.config.ts +++ b/packages/launchpad/cypress.config.ts @@ -28,6 +28,7 @@ export default defineConfig({ baseUrl: 'http://localhost:5555', supportFile: 'cypress/e2e/support/e2eSupport.ts', async setupNodeEvents (on, config) { + delete process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF = 'true' const { e2ePluginSetup } = require('@packages/frontend-shared/cypress/e2e/e2ePluginSetup') diff --git a/packages/launchpad/package.json b/packages/launchpad/package.json index dae40e883a59..844b8ad96077 100644 --- a/packages/launchpad/package.json +++ b/packages/launchpad/package.json @@ -9,10 +9,11 @@ "clean-deps": "rimraf node_modules", "test": "yarn cypress:run:ct && yarn types", "windi": "yarn windicss-analysis", - "cypress:open": "cross-env TZ=America/New_York gulp open --project .", - "cypress:open:ct": "cross-env TZ=America/New_York gulp open --component --project .", - "cypress:run:ct": "cross-env TZ=America/New_York node ../../scripts/cypress run --component --project .", - "cypress:run:e2e": "cross-env TZ=America/New_York node ../../scripts/cypress run --e2e --project .", + "cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 TZ=America/New_York", + "cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", + "cypress:open:ct": "yarn cypress:run-cypress-in-cypress gulp open --component --project .", + "cypress:run:ct": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --component --project .", + "cypress:run:e2e": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --e2e --project .", "dev": "yarn gulp dev --project .", "start": "echo 'run yarn dev from the root' && exit 1", "watch": "echo 'run yarn dev from the root' && exit 1", diff --git a/packages/packherd-require/src/loader.ts b/packages/packherd-require/src/loader.ts index f395aae9ec0b..63f612a3c8be 100644 --- a/packages/packherd-require/src/loader.ts +++ b/packages/packherd-require/src/loader.ts @@ -12,8 +12,6 @@ import { strict as assert } from 'assert' const logDebug = debug('cypress-verbose:packherd:debug') const logTrace = debug('cypress-verbose:packherd:trace') -const logSilly = debug('cypress-verbose:packherd:silly') -const logWarn = debug('cypress:packherd:warn') /** * Provides information that is used to resolve a module's key from its URI. @@ -869,11 +867,6 @@ export class PackherdModuleLoader { this.definitionHits.add(mod.id) return { mod, origin } - } catch (err: any) { - logWarn(err.message) - logSilly(err) - - return { mod: undefined, origin } } finally { this.loading.finish(fullPath) } diff --git a/packages/server/index.js b/packages/server/index.js index 56d877ed6f89..e5a5d503a7c1 100644 --- a/packages/server/index.js +++ b/packages/server/index.js @@ -1,7 +1,12 @@ -const { initializeStartTime } = require('./lib/util/performance_benchmark') +const runChildProcess = async (entryPoint) => { + require('./lib/plugins/child/register_ts_node') + require(entryPoint) +} const startCypress = async () => { try { + const { initializeStartTime } = require('./lib/util/performance_benchmark') + initializeStartTime() const { hookRequire } = require('./hook-require') @@ -16,4 +21,10 @@ const startCypress = async () => { } } -module.exports = startCypress() +const { entryPoint } = require('minimist')(process.argv.slice(1)) + +if (entryPoint) { + module.exports = runChildProcess(entryPoint) +} else { + module.exports = startCypress() +} diff --git a/scripts/after-pack-hook.js b/scripts/after-pack-hook.js index 1a2f9a83a391..3723d97e40ee 100644 --- a/scripts/after-pack-hook.js +++ b/scripts/after-pack-hook.js @@ -10,67 +10,74 @@ const { buildEntryPointAndCleanup } = require('./binary/binary-cleanup') const { getIntegrityCheckSource, getBinaryEntryPointSource } = require('./binary/binary-sources') module.exports = async function (params) { - console.log('****************************') - console.log('After pack hook') - console.log(params.appOutDir) - console.log(params.outDir) - console.log(params.electronPlatformName) - console.log('****************************') - - const packages = glob.sync('packages/*/node_modules', { - cwd: params.packager.info._appDir, - }) - - const buildSubfoldersPerPlatform = { - darwin: join('Cypress.app', 'Contents', 'Resources', 'app'), - linux: join('resources', 'app'), - win32: join('resources', 'app'), // TODO check this path - } - const buildSubfolder = buildSubfoldersPerPlatform[os.platform()] - const outputFolder = join(params.appOutDir, buildSubfolder) + try { + console.log('****************************') + console.log('After pack hook') + console.log(params.appOutDir) + console.log(params.outDir) + console.log(params.electronPlatformName) + console.log('****************************') - console.log('copying node_modules to', outputFolder) + const packages = glob.sync('packages/*/node_modules', { + cwd: params.packager.info._appDir, + }) - for await (const packageNodeModules of packages) { - console.log('copying', packageNodeModules) + const buildSubfoldersPerPlatform = { + darwin: join('Cypress.app', 'Contents', 'Resources', 'app'), + linux: join('resources', 'app'), + win32: join('resources', 'app'), // TODO check this path + } + const buildSubfolder = buildSubfoldersPerPlatform[os.platform()] + const outputFolder = join(params.appOutDir, buildSubfolder) - const sourceFolder = join(params.packager.info._appDir, packageNodeModules) - const destinationFolder = join(outputFolder, packageNodeModules) + console.log('copying node_modules to', outputFolder) - await fs.copy(sourceFolder, destinationFolder) - } + for await (const packageNodeModules of packages) { + console.log('copying', packageNodeModules) - const distNodeModules = path.join(params.packager.info._appDir, 'node_modules') - const appNodeModules = path.join(outputFolder, 'node_modules') + const sourceFolder = join(params.packager.info._appDir, packageNodeModules) + const destinationFolder = join(outputFolder, packageNodeModules) - console.log('copying ', distNodeModules, ' to', appNodeModules) + await fs.copy(sourceFolder, destinationFolder) + } - await fs.copy(distNodeModules, appNodeModules) + const distNodeModules = path.join(params.packager.info._appDir, 'node_modules') + const appNodeModules = path.join(outputFolder, 'node_modules') - console.log('all node_modules subfolders copied to', outputFolder) + console.log('copying ', distNodeModules, ' to', appNodeModules) - const exePathPerPlatform = { - darwin: join(params.appOutDir, 'Cypress.app', 'Contents', 'MacOS', 'Cypress'), - linux: join(params.appOutDir, 'Cypress'), - win32: join(params.appOutDir, 'Cypress.exe'), - } + await fs.copy(distNodeModules, appNodeModules) - if (!['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE)) { - await fs.writeFile(path.join(outputFolder, 'index.js'), getBinaryEntryPointSource()) - - await flipFuses( - exePathPerPlatform[os.platform()], - { - version: FuseVersion.V1, - [FuseV1Options.LoadBrowserProcessSpecificV8Snapshot]: true, - }, - ) - - // Build out the entry point and clean up prior to setting up v8 snapshots so that the state of the binary is correct - await buildEntryPointAndCleanup(outputFolder) - await setupV8Snapshots({ - cypressAppPath: params.appOutDir, - integrityCheckSource: getIntegrityCheckSource(outputFolder), - }) + console.log('all node_modules subfolders copied to', outputFolder) + + const exePathPerPlatform = { + darwin: join(params.appOutDir, 'Cypress.app', 'Contents', 'MacOS', 'Cypress'), + linux: join(params.appOutDir, 'Cypress'), + win32: join(params.appOutDir, 'Cypress.exe'), + } + + if (!['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE)) { + const binaryEntryPointSource = await getBinaryEntryPointSource() + + await fs.writeFile(path.join(outputFolder, 'index.js'), binaryEntryPointSource) + + await flipFuses( + exePathPerPlatform[os.platform()], + { + version: FuseVersion.V1, + [FuseV1Options.LoadBrowserProcessSpecificV8Snapshot]: true, + }, + ) + + // Build out the entry point and clean up prior to setting up v8 snapshots so that the state of the binary is correct + await buildEntryPointAndCleanup(outputFolder) + await setupV8Snapshots({ + cypressAppPath: params.appOutDir, + integrityCheckSource: getIntegrityCheckSource(outputFolder), + }) + } + } catch (error) { + console.log(error) + throw error } } diff --git a/scripts/binary/binary-entry-point-source.js b/scripts/binary/binary-entry-point-source.js index ddf0469eeebf..fcab4c31418c 100644 --- a/scripts/binary/binary-entry-point-source.js +++ b/scripts/binary/binary-entry-point-source.js @@ -3,7 +3,7 @@ const path = require('path') process.env.CYPRESS_INTERNAL_ENV = process.env.CYPRESS_INTERNAL_ENV || 'production' try { - require('./node_modules/bytenode/lib/index.js') + require('bytenode') const filename = path.join(__dirname, 'packages', 'server', 'index.jsc') const dirname = path.dirname(filename) diff --git a/scripts/binary/binary-integrity-check-source.js b/scripts/binary/binary-integrity-check-source.js index cec2c9316ca9..59f4a89cf98b 100644 --- a/scripts/binary/binary-integrity-check-source.js +++ b/scripts/binary/binary-integrity-check-source.js @@ -143,9 +143,9 @@ function integrityCheck (options) { fileName: 'evalmachine.', }, { - functionName: 'Module._extensions.', + functionName: 'Module2._extensions.', // eslint-disable-next-line no-undef - fileName: [appPath, 'node_modules', 'bytenode', 'lib', 'index.js'].join(PATH_SEP), + fileName: [appPath, 'index.js'].join(PATH_SEP), }, { // eslint-disable-next-line no-undef @@ -164,15 +164,6 @@ function integrityCheck (options) { errorMessage: 'Integrity check failed for main index.js file', }) - validateFile({ - // eslint-disable-next-line no-undef - filePath: [appPath, 'node_modules', 'bytenode', 'lib', 'index.js'].join(PATH_SEP), - crypto, - fs, - expectedHash: 'BYTENODE_HASH', - errorMessage: 'Integrity check failed for main bytenode.js file', - }) - validateFile({ // eslint-disable-next-line no-undef filePath: [appPath, 'packages', 'server', 'index.jsc'].join(PATH_SEP), diff --git a/scripts/binary/binary-sources.js b/scripts/binary/binary-sources.js index 077ff675dd28..2e9d1ade817a 100644 --- a/scripts/binary/binary-sources.js +++ b/scripts/binary/binary-sources.js @@ -1,6 +1,7 @@ const fs = require('fs') const crypto = require('crypto') const path = require('path') +const esbuild = require('esbuild') const escapeString = (string) => string.replaceAll(`\``, `\\\``).replaceAll(`$`, `\\$`) @@ -10,8 +11,15 @@ function read (file) { return fs.readFileSync(pathToFile, 'utf8') } -const getBinaryEntryPointSource = () => { - return read('binary-entry-point-source.js') +const getBinaryEntryPointSource = async () => { + const esbuildResult = await esbuild.build({ + entryPoints: [require.resolve('./binary-entry-point-source.js')], + bundle: true, + platform: 'node', + write: false, + }) + + return esbuildResult.outputFiles[0].text } const getIntegrityCheckSource = (baseDirectory) => { @@ -19,12 +27,10 @@ const getIntegrityCheckSource = (baseDirectory) => { const secret = require('crypto').randomBytes(48).toString('hex') const mainIndexHash = crypto.createHmac('md5', secret).update(fs.readFileSync(path.join(baseDirectory, './index.js'), 'utf8')).digest('hex') - const bytenodeHash = crypto.createHmac('md5', secret).update(fs.readFileSync(path.join(baseDirectory, './node_modules/bytenode/lib/index.js'), 'utf8')).digest('hex') const indexJscHash = crypto.createHmac('md5', secret).update(fs.readFileSync(path.join(baseDirectory, './packages/server/index.jsc'), 'utf8')).digest('hex') return fileSource.split('\n').join(`\n `) .replaceAll('MAIN_INDEX_HASH', mainIndexHash) - .replaceAll('BYTENODE_HASH', bytenodeHash) .replaceAll('INDEX_JSC_HASH', indexJscHash) .replaceAll('HMAC_SECRET', secret) .replaceAll('CRYPTO_CREATE_HMAC_TO_STRING', escapeString(crypto.createHmac.toString())) diff --git a/scripts/binary/build.ts b/scripts/binary/build.ts index 65a85334d4df..5215733c82c6 100644 --- a/scripts/binary/build.ts +++ b/scripts/binary/build.ts @@ -176,7 +176,6 @@ export async function buildCypressApp (options: BuildCypressAppOpts) { fs.writeFileSync(meta.distDir('index.js'), `\ process.env.CYPRESS_INTERNAL_ENV = process.env.CYPRESS_INTERNAL_ENV || 'production' -require('./node_modules/bytenode/lib/index.js') require('./packages/server/index.js') `) diff --git a/scripts/binary/smoke.js b/scripts/binary/smoke.js index 3ab72696bb05..063ad600ea24 100644 --- a/scripts/binary/smoke.js +++ b/scripts/binary/smoke.js @@ -264,7 +264,6 @@ const runIntegrityTest = async function (buildAppExecutable, buildAppDir, e2e) { await testCorruptingFile(path.join(buildAppDir, 'index.js'), 'Integrity check failed for main index.js file') await testCorruptingFile(path.join(buildAppDir, 'packages', 'server', 'index.jsc'), 'Integrity check failed for main server index.jsc file') - await testCorruptingFile(path.join(buildAppDir, 'node_modules', 'bytenode', 'lib', 'index.js'), 'Integrity check failed for main bytenode.js file') const testAlteringEntryPoint = async (additionalCode, errorMessage) => { const packageJsonContents = await fs.readJSON(path.join(buildAppDir, 'package.json')) diff --git a/tooling/v8-snapshot/cache/prod-darwin/snapshot-meta.cache.json b/tooling/v8-snapshot/cache/prod-darwin/snapshot-meta.cache.json index b5b881125887..a4d732dae7c0 100644 --- a/tooling/v8-snapshot/cache/prod-darwin/snapshot-meta.cache.json +++ b/tooling/v8-snapshot/cache/prod-darwin/snapshot-meta.cache.json @@ -4,10 +4,6 @@ "./get-stream/buffer-stream.js", "./graceful-fs/polyfills.js", "./lockfile/lockfile.js", - "./node_modules/@babel/traverse/lib/path/comments.js", - "./node_modules/@babel/traverse/lib/path/conversion.js", - "./node_modules/@babel/traverse/lib/path/family.js", - "./node_modules/@babel/traverse/lib/path/introspection.js", "./node_modules/@cspotcode/source-map-support/source-map-support.js", "./node_modules/@cypress/commit-info/node_modules/debug/src/node.js", "./node_modules/@cypress/get-windows-proxy/node_modules/debug/src/node.js", @@ -44,6 +40,10 @@ "./node_modules/tcp-port-used/node_modules/debug/src/node.js", "./node_modules/trash/node_modules/make-dir/index.js", "./node_modules/utif/UTIF.js", + "./packages/config/node_modules/@babel/traverse/lib/path/comments.js", + "./packages/config/node_modules/@babel/traverse/lib/path/conversion.js", + "./packages/config/node_modules/@babel/traverse/lib/path/family.js", + "./packages/config/node_modules/@babel/traverse/lib/path/introspection.js", "./packages/data-context/node_modules/debug/src/node.js", "./packages/data-context/node_modules/minimatch/minimatch.js", "./packages/graphql/node_modules/debug/src/node.js", @@ -54,6 +54,7 @@ "./packages/server/lib/capture.js", "./packages/server/lib/cloud/exception.ts", "./packages/server/lib/errors.ts", + "./packages/server/lib/makeDataContext.ts", "./packages/server/lib/modes/record.js", "./packages/server/lib/modes/run.ts", "./packages/server/lib/open_project.ts", @@ -75,17 +76,6 @@ "deferred": [ "./node_modules/@babel/generator/lib/node/index.js", "./node_modules/@babel/generator/lib/node/whitespace.js", - "./node_modules/@babel/helper-environment-visitor/lib/index.js", - "./node_modules/@babel/traverse/lib/context.js", - "./node_modules/@babel/traverse/lib/index.js", - "./node_modules/@babel/traverse/lib/path/ancestry.js", - "./node_modules/@babel/traverse/lib/path/context.js", - "./node_modules/@babel/traverse/lib/path/index.js", - "./node_modules/@babel/traverse/lib/path/modification.js", - "./node_modules/@babel/traverse/lib/path/removal.js", - "./node_modules/@babel/traverse/lib/path/replacement.js", - "./node_modules/@babel/traverse/lib/scope/index.js", - "./node_modules/@babel/traverse/lib/traverse-node.js", "./node_modules/@babel/types/lib/definitions/core.js", "./node_modules/@babel/types/lib/definitions/experimental.js", "./node_modules/@babel/types/lib/definitions/flow.js", @@ -630,6 +620,15 @@ "./node_modules/yauzl/index.js", "./node_modules/zip-stream/index.js", "./packages/config/index.js", + "./packages/config/node_modules/@babel/traverse/lib/context.js", + "./packages/config/node_modules/@babel/traverse/lib/index.js", + "./packages/config/node_modules/@babel/traverse/lib/path/ancestry.js", + "./packages/config/node_modules/@babel/traverse/lib/path/context.js", + "./packages/config/node_modules/@babel/traverse/lib/path/index.js", + "./packages/config/node_modules/@babel/traverse/lib/path/modification.js", + "./packages/config/node_modules/@babel/traverse/lib/path/removal.js", + "./packages/config/node_modules/@babel/traverse/lib/path/replacement.js", + "./packages/config/node_modules/@babel/traverse/lib/scope/index.js", "./packages/config/src/ast-utils/addToCypressConfig.ts", "./packages/config/src/ast-utils/addToCypressConfigPlugin.ts", "./packages/config/src/browser.ts", @@ -844,7 +843,6 @@ "./packages/server/lib/environment.js", "./packages/server/lib/gui/windows.ts", "./packages/server/lib/log.js", - "./packages/server/lib/makeDataContext.ts", "./packages/server/lib/modes/interactive.ts", "./packages/server/lib/plugins/dev-server.js", "./packages/server/lib/plugins/preprocessor.js", @@ -1028,18 +1026,6 @@ "./node_modules/@babel/template/lib/parse.js", "./node_modules/@babel/template/lib/populate.js", "./node_modules/@babel/template/lib/string.js", - "./node_modules/@babel/traverse/lib/cache.js", - "./node_modules/@babel/traverse/lib/hub.js", - "./node_modules/@babel/traverse/lib/path/evaluation.js", - "./node_modules/@babel/traverse/lib/path/inference/index.js", - "./node_modules/@babel/traverse/lib/path/inference/inferer-reference.js", - "./node_modules/@babel/traverse/lib/path/inference/inferers.js", - "./node_modules/@babel/traverse/lib/path/lib/hoister.js", - "./node_modules/@babel/traverse/lib/path/lib/removal-hooks.js", - "./node_modules/@babel/traverse/lib/path/lib/virtual-types.js", - "./node_modules/@babel/traverse/lib/scope/binding.js", - "./node_modules/@babel/traverse/lib/scope/lib/renamer.js", - "./node_modules/@babel/traverse/lib/visitors.js", "./node_modules/@babel/types/lib/asserts/assertNode.js", "./node_modules/@babel/types/lib/asserts/generated/index.js", "./node_modules/@babel/types/lib/ast-types/generated/index.js", @@ -3508,6 +3494,18 @@ "./node_modules/yn/index.js", "./node_modules/yn/lenient.js", "./package.json", + "./packages/config/node_modules/@babel/traverse/lib/cache.js", + "./packages/config/node_modules/@babel/traverse/lib/hub.js", + "./packages/config/node_modules/@babel/traverse/lib/path/evaluation.js", + "./packages/config/node_modules/@babel/traverse/lib/path/inference/index.js", + "./packages/config/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js", + "./packages/config/node_modules/@babel/traverse/lib/path/inference/inferers.js", + "./packages/config/node_modules/@babel/traverse/lib/path/lib/hoister.js", + "./packages/config/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js", + "./packages/config/node_modules/@babel/traverse/lib/path/lib/virtual-types.js", + "./packages/config/node_modules/@babel/traverse/lib/scope/binding.js", + "./packages/config/node_modules/@babel/traverse/lib/scope/lib/renamer.js", + "./packages/config/node_modules/@babel/traverse/lib/visitors.js", "./packages/config/src/ast-utils/astConfigHelpers.ts", "./packages/config/src/utils.ts", "./packages/data-context/node_modules/@babel/code-frame/lib/index.js", @@ -3709,6 +3707,7 @@ "./packages/server/lib/automation/automation.ts", "./packages/server/lib/automation/index.ts", "./packages/server/lib/automation/screenshot.ts", + "./packages/server/lib/automation/util.ts", "./packages/server/lib/browsers/protocol.ts", "./packages/server/lib/cloud/machine_id.js", "./packages/server/lib/cloud/upload.ts", @@ -3934,5 +3933,5 @@ "./tooling/v8-snapshot/cache/prod-darwin/snapshot-entry.js" ], "deferredHashFile": "yarn.lock", - "deferredHash": "844da7908a41692a3b04716c88e2f0cdad85ece6f94f6ab89fbd1ffe5c332fd2" + "deferredHash": "1ebada20bbce44514cab9420511462a591efa7fbb0c00b64c4f72d31227714ca" } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 53974818eb58..0b0a4e7a1b80 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2204,7 +2204,7 @@ debug "^4.1.0" globals "^11.1.0" -"@babel/traverse@^7", "@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0", "@babel/traverse@^7.15.4", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9", "@babel/traverse@^7.4.3", "@babel/traverse@^7.6.0", "@babel/traverse@^7.7.0", "@babel/traverse@^7.9.0": +"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0", "@babel/traverse@^7.15.4", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.17.9", "@babel/traverse@^7.4.3", "@babel/traverse@^7.6.0", "@babel/traverse@^7.7.0", "@babel/traverse@^7.9.0": version "7.17.9" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.9.tgz#1f9b207435d9ae4a8ed6998b2b82300d83c37a0d" integrity sha512-PQO8sDIJ8SIwipTPiR71kJQCKQYB5NGImbOviK8K+kg5xkNSYXLBupuX9QhatFowrsvo9Hj8WgArg3W7ijNAQw== @@ -25383,11 +25383,6 @@ number-is-nan@^1.0.0: resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= -nvm@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/nvm/-/nvm-0.0.4.tgz#38a178e9d31b283508c92d15c9da861d1a9210bc" - integrity sha1-OKF46dMbKDUIyS0VydqGHRqSELw= - nwsapi@^2.0.7, nwsapi@^2.0.9, nwsapi@^2.1.3: version "2.2.0" resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.0.tgz#204879a9e3d068ff2a55139c2c772780681a38b7"