Comparing version 2.1.0 to 3.0.0-alpha.0
@@ -0,1 +1,2 @@ | ||
export declare function getServerInitPath_cli(): Promise<string>; | ||
export declare function getConfigFilesPaths_cli(): Promise<{ | ||
@@ -2,0 +3,0 @@ configFilePath: string; |
@@ -5,6 +5,7 @@ "use strict"; | ||
}); | ||
exports.getServerInitPath_cli = getServerInitPath_cli; | ||
exports.getConfigFilesPaths_cli = getConfigFilesPaths_cli; | ||
var _childProcess = _interopRequireDefault(require("child_process")); | ||
var _os = require("os"); | ||
var _path = _interopRequireDefault(require("path")); | ||
var _os = require("os"); | ||
var _debug = require("./debug"); | ||
@@ -46,2 +47,17 @@ var _binPath = require("./bin-path"); | ||
} | ||
function _getServerInitPath_cli() { | ||
_getServerInitPath_cli = _asyncToGenerator(function*() { | ||
(0, _debug).debug('Trying discovery via cypress CLI'); | ||
const cliBinPath = yield (0, _binPath).getCypressCLIBinPath(); | ||
const basePath = yield getBasePath(cliBinPath); | ||
(0, _debug).debug('Cypress base path is: %s', basePath); | ||
const version = yield getCypressVersion(cliBinPath); | ||
(0, _debug).debug('Cypress version is: %s', version); | ||
return _path.default.resolve(basePath, version, getPackagedPath(), 'index.js'); | ||
}); | ||
return _getServerInitPath_cli.apply(this, arguments); | ||
} | ||
function getServerInitPath_cli() { | ||
return _getServerInitPath_cli.apply(this, arguments); | ||
} | ||
function _getConfigFilesPaths_cli() { | ||
@@ -55,4 +71,4 @@ _getConfigFilesPaths_cli = _asyncToGenerator(function*() { | ||
(0, _debug).debug('Cypress version is: %s', version); | ||
const configFilePath = _path.default.resolve(basePath, version, getPackagedPath(), 'app.yml'); | ||
const backupConfigFilePath = _path.default.resolve(basePath, version, getPackagedPath(), '_app.yml'); | ||
const configFilePath = _path.default.resolve(basePath, version, getPackagedPath(), 'packages/server/config/app.yml'); | ||
const backupConfigFilePath = _path.default.resolve(basePath, version, getPackagedPath(), 'packages/server/config/_app.yml'); | ||
return { | ||
@@ -98,5 +114,5 @@ configFilePath, | ||
if ((0, _os).platform() === 'win32') { | ||
return 'Cypress/resources/app/packages/server/config'; | ||
return 'Cypress/resources/app'; | ||
} | ||
return 'Cypress.app/Contents/Resources/app/packages/server/config'; | ||
return 'Cypress.app/Contents/Resources/app'; | ||
} | ||
@@ -103,0 +119,0 @@ function execute(command) { |
export declare function getPkgRootFromElectronBinary(binaryPath: string): string; | ||
export declare function getConfigFromElectronBinary(binaryPath: string): import("./files").ConfigFiles; | ||
export declare function getServerInitFromElectronBinary(binaryPath: string): string; |
@@ -7,4 +7,5 @@ "use strict"; | ||
exports.getConfigFromElectronBinary = getConfigFromElectronBinary; | ||
exports.getServerInitFromElectronBinary = getServerInitFromElectronBinary; | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _os = require("os"); | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _path = _interopRequireDefault(require("path")); | ||
@@ -37,1 +38,5 @@ var _files = require("./files"); | ||
} | ||
function getServerInitFromElectronBinary(binaryPath) { | ||
_fs.default.statSync(binaryPath); | ||
return (0, _files).getServerInit(getPkgRootFromElectronBinary(binaryPath)); | ||
} |
@@ -0,1 +1,2 @@ | ||
export declare function getServerInitPaths_stateModule(): Promise<string>; | ||
export declare function getConfigFilesPaths_stateModule(): Promise<import("./files").ConfigFiles>; |
@@ -5,8 +5,9 @@ "use strict"; | ||
}); | ||
exports.getServerInitPaths_stateModule = getServerInitPaths_stateModule; | ||
exports.getConfigFilesPaths_stateModule = getConfigFilesPaths_stateModule; | ||
var _path = _interopRequireDefault(require("path")); | ||
var _binPath = require("./bin-path"); | ||
var _debug = require("./debug"); | ||
var _binPath = require("./bin-path"); | ||
var _files = require("./files"); | ||
var _fs = require("./fs"); | ||
var _files = require("./files"); | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
@@ -46,2 +47,18 @@ try { | ||
} | ||
function _getServerInitPaths_stateModule() { | ||
_getServerInitPaths_stateModule = _asyncToGenerator(function*() { | ||
(0, _debug).debug('Trying discovery via state module'); | ||
const stateModulePath = yield getStateModulePath(); | ||
const state = require(stateModulePath); | ||
const pkgPath = state.getBinaryPkgPath(state.getBinaryDir()); | ||
(0, _debug).debug('Cypress pkgPath: %s', pkgPath); | ||
const pkgRoot = _path.default.dirname(pkgPath); | ||
(0, _debug).debug('Cypress pkgRoot: %s', pkgRoot); | ||
return (0, _files).getServerInit(pkgRoot); | ||
}); | ||
return _getServerInitPaths_stateModule.apply(this, arguments); | ||
} | ||
function getServerInitPaths_stateModule() { | ||
return _getServerInitPaths_stateModule.apply(this, arguments); | ||
} | ||
function _getConfigFilesPaths_stateModule() { | ||
@@ -48,0 +65,0 @@ _getConfigFilesPaths_stateModule = _asyncToGenerator(function*() { |
import { ConfigFiles } from 'files'; | ||
export declare function getConfigFilesPaths(cypressConfigFilePath?: string | null): Promise<ConfigFiles>; | ||
export declare function getServerInitPath(): Promise<string>; |
@@ -6,2 +6,3 @@ "use strict"; | ||
exports.getConfigFilesPaths = getConfigFilesPaths; | ||
exports.getServerInitPath = getServerInitPath; | ||
var _fs = _interopRequireDefault(require("fs")); | ||
@@ -71,2 +72,16 @@ var _path = _interopRequireDefault(require("path")); | ||
} | ||
function _getServerInitPath() { | ||
_getServerInitPath = _asyncToGenerator(function*() { | ||
if (typeof process.env.CYPRESS_RUN_BINARY === 'string') { | ||
(0, _debug).debug('CYPRESS_RUN_BINARY: %s', process.env.CYPRESS_RUN_BINARY); | ||
return tryAll(()=>(0, _discoveryRunBinary).getServerInitFromElectronBinary(process.env.CYPRESS_RUN_BINARY) | ||
); | ||
} | ||
return tryAll(_discoveryStateModule.getServerInitPaths_stateModule, _discoveryCli.getServerInitPath_cli); | ||
}); | ||
return _getServerInitPath.apply(this, arguments); | ||
} | ||
function getServerInitPath() { | ||
return _getServerInitPath.apply(this, arguments); | ||
} | ||
function _tryAll() { | ||
@@ -73,0 +88,0 @@ _tryAll = _asyncToGenerator(function*(...fns) { |
@@ -6,1 +6,2 @@ export declare type ConfigFiles = { | ||
export declare const getConfigFiles: (pkgRoot: string) => ConfigFiles; | ||
export declare const getServerInit: (pkgRoot: string) => string; |
@@ -5,3 +5,3 @@ "use strict"; | ||
}); | ||
exports.getConfigFiles = void 0; | ||
exports.getServerInit = exports.getConfigFiles = void 0; | ||
var _path = _interopRequireDefault(require("path")); | ||
@@ -24,1 +24,7 @@ var _debug = require("./debug"); | ||
exports.getConfigFiles = getConfigFiles; | ||
const getServerInit = (pkgRoot)=>{ | ||
const result = _path.default.resolve(pkgRoot, 'index.js'); | ||
(0, _debug).debug('Cypress installation server init: %s', result); | ||
return result; | ||
}; | ||
exports.getServerInit = getServerInit; |
@@ -1,3 +0,1 @@ | ||
import * as lib from './patch'; | ||
export declare const patch: typeof lib.patch; | ||
export declare const run: (cypressAPIUrl?: string, label?: string, cypressConfigFilePath?: string | undefined) => Promise<void>; | ||
export declare const run: (moduleAbsolutePath: string) => Promise<void>; |
@@ -5,3 +5,3 @@ "use strict"; | ||
}); | ||
exports.patch = exports.run = void 0; | ||
exports.run = void 0; | ||
var lib = _interopRequireWildcard(require("./patch")); | ||
@@ -60,19 +60,6 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
} | ||
const DEFAULT_OVERRIDE_URL = 'https://api.cypress.io/'; | ||
const patch = lib.patch; | ||
exports.patch = patch; | ||
const run = _asyncToGenerator(function*(cypressAPIUrl = DEFAULT_OVERRIDE_URL, label = 'cy2', cypressConfigFilePath = process.env.CYPRESS_PACKAGE_CONFIG_PATH) { | ||
yield lib.patch(cypressAPIUrl, cypressConfigFilePath); | ||
console.log(`[${label}] Running cypress with API URL: ${cypressAPIUrl}`); | ||
const child = yield lib.run(); | ||
child.on('close', _asyncToGenerator(function*(code) { | ||
yield patch(DEFAULT_OVERRIDE_URL); | ||
process.exit(code !== null && code !== void 0 ? code : 1); | ||
})); | ||
process.on('SIGINT', _asyncToGenerator(function*() { | ||
yield patch(DEFAULT_OVERRIDE_URL); | ||
child.kill('SIGINT'); | ||
process.exit(1); | ||
})); | ||
const run = _asyncToGenerator(function*(moduleAbsolutePath) { | ||
yield lib.patchServerInit(moduleAbsolutePath); | ||
yield lib.run(); | ||
}); | ||
exports.run = run; |
import cp from 'child_process'; | ||
/** | ||
* Patch Cypress init script | ||
* | ||
* @param {string} injectedAbsolutePath - JS module to be injected into Cypress | ||
*/ | ||
export declare function patchServerInit(injectedAbsolutePath: string): Promise<void>; | ||
/** | ||
* Patch Cypress with a custom API URL. | ||
@@ -4,0 +10,0 @@ * |
@@ -5,2 +5,3 @@ "use strict"; | ||
}); | ||
exports.patchServerInit = patchServerInit; | ||
exports.patch = patch; | ||
@@ -48,2 +49,25 @@ exports.run = run; | ||
} | ||
function _patchServerInit() { | ||
_patchServerInit = _asyncToGenerator(function*(injectedAbsolutePath) { | ||
const serverInitPath = yield (0, _discovery).getServerInitPath(); | ||
(0, _debug).debug('Patching cypress entry point file: %s', serverInitPath); | ||
const doc = _fs.default.readFileSync(serverInitPath, 'utf8'); | ||
if (doc.includes(injectedAbsolutePath)) { | ||
return; | ||
} | ||
_fs.default.writeFileSync(serverInitPath, ` | ||
try { | ||
require('${injectedAbsolutePath}'); | ||
} catch (e) { | ||
// noop | ||
} | ||
${doc} | ||
`); | ||
}); | ||
return _patchServerInit.apply(this, arguments); | ||
} | ||
function patchServerInit(injectedAbsolutePath) { | ||
return _patchServerInit.apply(this, arguments); | ||
} | ||
function _patch() { | ||
@@ -50,0 +74,0 @@ _patch = _asyncToGenerator(function*(apiURL, cypressConfigFilePath) { |
{ | ||
"name": "cy2", | ||
"version": "2.1.0", | ||
"version": "3.0.0-alpha.0", | ||
"author": "Andrew Goldis", | ||
@@ -5,0 +5,0 @@ "main": "./dist", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
37892
30
848
2
18