Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cy2

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cy2 - npm Package Compare versions

Comparing version 3.1.2 to 3.1.3

dist/context.d.ts

94

dist/bin-path.js

@@ -7,6 +7,37 @@ "use strict";

var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
var _npmWhich = _interopRequireDefault(require("npm-which"));
var _os = require("os");
var _path = _interopRequireWildcard(require("path"));
var _util = require("util");
var _context = require("./context");
var _debug = require("./debug");
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function() {
var self = this, args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _interopRequireDefault(obj) {

@@ -17,15 +48,56 @@ return obj && obj.__esModule ? obj : {

}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {
};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
}
newObj.default = obj;
return newObj;
}
}
function _getCypressCLIBinPath() {
_getCypressCLIBinPath = _asyncToGenerator(function*() {
let cliBinPath = null;
const ctx = (0, _context).getContext();
if (ctx === null || ctx === void 0 ? void 0 : ctx.has('cypressPackagePath')) {
cliBinPath = _path.default.join((0, _path).dirname(ctx.get('cypressPackagePath')), 'bin', 'cypress');
} else {
cliBinPath = yield whichCypress();
}
if (!cliBinPath) {
throw new Error('Cannot detect cypress package executable script');
}
const packagePath = _path.default.normalize(_fs.default.realpathSync(cliBinPath));
(0, _debug).debug('Cypress normalized binary path: %s', packagePath);
return packagePath;
});
return _getCypressCLIBinPath.apply(this, arguments);
}
function getCypressCLIBinPath() {
return new Promise((resolve, reject)=>{
return _getCypressCLIBinPath.apply(this, arguments);
}
function _whichCypress() {
_whichCypress = _asyncToGenerator(function*() {
const location = (0, _os).platform() === 'win32' ? process.cwd() : __dirname;
(0, _npmWhich).default(location)('cypress', function(err, binaryCypress) {
if (err) {
return reject(err);
}
(0, _debug).debug('Cypress binary: %s', binaryCypress);
const packagePath = _path.default.normalize(_fs.default.realpathSync(binaryCypress));
(0, _debug).debug('Cypress normalized binary path: %s', packagePath);
return resolve(packagePath);
});
const pWhich = (0, _util).promisify((0, _npmWhich).default(location));
return pWhich('cypress');
});
return _whichCypress.apply(this, arguments);
}
function whichCypress() {
return _whichCypress.apply(this, arguments);
}

2

dist/cli.js

@@ -38,3 +38,3 @@ "use strict";

if (!process.env.CYPRESS_API_URL) {
throw new Error('Missing CYPRESS_API_URL environment variable pointing to sorry-cypress director serice');
throw new Error('Missing CYPRESS_API_URL environment variable pointing to sorry-cypress director service');
}

@@ -41,0 +41,0 @@ yield (0, _index).run();

@@ -1,2 +0,2 @@

export declare function getServerInitPaths_stateModule(): Promise<string>;
export declare function getServerInitPath_stateModule(): Promise<string>;
export declare function getConfigFilesPaths_stateModule(): Promise<import("./files").ConfigFiles>;

@@ -5,3 +5,3 @@ "use strict";

});
exports.getServerInitPaths_stateModule = getServerInitPaths_stateModule;
exports.getServerInitPath_stateModule = getServerInitPath_stateModule;
exports.getConfigFilesPaths_stateModule = getConfigFilesPaths_stateModule;

@@ -47,4 +47,4 @@ var _path = _interopRequireDefault(require("path"));

}
function _getServerInitPaths_stateModule() {
_getServerInitPaths_stateModule = _asyncToGenerator(function*() {
function _getServerInitPath_stateModule() {
_getServerInitPath_stateModule = _asyncToGenerator(function*() {
(0, _debug).debug('Trying discovery via state module');

@@ -59,6 +59,6 @@ const stateModulePath = yield getStateModulePath();

});
return _getServerInitPaths_stateModule.apply(this, arguments);
return _getServerInitPath_stateModule.apply(this, arguments);
}
function getServerInitPaths_stateModule() {
return _getServerInitPaths_stateModule.apply(this, arguments);
function getServerInitPath_stateModule() {
return _getServerInitPath_stateModule.apply(this, arguments);
}

@@ -65,0 +65,0 @@ function _getConfigFilesPaths_stateModule() {

@@ -78,3 +78,3 @@ "use strict";

}
return tryAll(_discoveryStateModule.getServerInitPaths_stateModule, _discoveryCli.getServerInitPath_cli);
return tryAll(_discoveryStateModule.getServerInitPath_stateModule, _discoveryCli.getServerInitPath_cli);
});

@@ -81,0 +81,0 @@ return _getServerInitPath.apply(this, arguments);

@@ -1,4 +0,10 @@

import * as lib from './patch';
export declare const patch: () => Promise<void>;
/**
* Patch cypress for subsequent programmatic invocation.
* The actual dashboard url is set via process.env.CYPRESS_API_URL.
* For SorryCypress it should point to the director service.
*
* @param cypressPackagePath - path to cypress npm package enyty point
*/
export declare const patch: (cypressPackagePath?: string) => Promise<void>;
export declare const run: (label?: string) => Promise<void>;
export declare const inject: typeof lib.patchServerInit;
export declare const inject: (injectedAbsolutePath: string, cypressPackagePath?: string) => Promise<void>;

@@ -6,2 +6,3 @@ "use strict";

exports.patch = exports.run = exports.inject = void 0;
var _context = require("./context");
var lib = _interopRequireWildcard(require("./patch"));

@@ -60,4 +61,5 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {

}
const patch = _asyncToGenerator(function*() {
yield lib.patchServerInit(`${__dirname}/injected.js`);
const patch = _asyncToGenerator(function*(cypressPackagePath = require.resolve('cypress')) {
yield (0, _context).runInContext(()=>lib.patchServerInit(`${__dirname}/injected.js`)
, new Map().set('cypressPackagePath', cypressPackagePath));
});

@@ -71,3 +73,6 @@ exports.patch = patch;

exports.run = run;
const inject = lib.patchServerInit;
const inject = _asyncToGenerator(function*(injectedAbsolutePath, cypressPackagePath = require.resolve('cypress')) {
yield (0, _context).runInContext(()=>lib.patchServerInit(injectedAbsolutePath)
, new Map().set('cypressPackagePath', cypressPackagePath));
});
exports.inject = inject;
{
"name": "cy2",
"version": "3.1.2",
"version": "3.1.3",
"author": "Andrew Goldis",

@@ -5,0 +5,0 @@ "main": "./dist",

@@ -34,5 +34,6 @@ # cy2

CLI usage - use `http://localhost:1234` as Cypress:
CLI usage
```sh
# use `http://localhost:1234` as Cypress Dashboard
CYPRESS_API_URL="http://localhost:1234/" cy2 run --parallel --record --key somekey --ci-build-id hello-cypress

@@ -51,21 +52,8 @@ ```

Starting version 3+, the API methods `run` and `patch` rely on `process.env.CYPRESS_API_URL` - they do not accept any argument. That's because of a new patching method that doesn't permanently change cypress installation after invoking `cy2`.
Starting version 3+, the API methods `run` and `patch` rely on `process.env.CYPRESS_API_URL` instead of accepting an argument. That's because of a new patching method that doesn't permanently change cypress configuration after invoking `cy2`.
### Run Cypress programmatically
### Patch Cypress programmatically without running
⚠️ Make sure to set `process.env.CYPRESS_API_URL` before invoking `run`
`patch(cypressPackageEntryPath: string) => Promise<void>`
```ts
import { run } from 'cy2';
process.env.CYPRESS_API_URL = 'https://dashboard.servuce.url';
run().catch((error) => {
console.error(error);
process.exit(1);
});
```
### Patch Cypress without running
⚠️ Make sure to set `process.env.CYPRESS_API_URL` before invoking `patch`

@@ -80,3 +68,4 @@

async function main() {
await patch();
// optional - provide cypress package main entry point location
await patch(require.resolve('cypress'));

@@ -83,0 +72,0 @@ cypress

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc