Comparing version 1.2.1 to 1.3.0
@@ -0,1 +1,9 @@ | ||
# [1.3.0](https://github.com/sorry-cypress/cy2/compare/v1.2.1...v1.3.0) (2021-09-08) | ||
### Features | ||
* add debug ([#15](https://github.com/sorry-cypress/cy2/issues/15)) ([c455cd5](https://github.com/sorry-cypress/cy2/commit/c455cd531f8ee3c255e81efae9de91a4065a6d40)) | ||
* use __dirname instead of cwd ([#14](https://github.com/sorry-cypress/cy2/issues/14)) ([95561ea](https://github.com/sorry-cypress/cy2/commit/95561ea14362260be0dd6627f1697c3d86007d4d)) | ||
## [1.2.1](https://github.com/sorry-cypress/cy2/compare/v1.2.0...v1.2.1) (2021-05-11) | ||
@@ -2,0 +10,0 @@ |
const path = require('path'); | ||
const fs = require('fs'); | ||
const cp = require('child_process'); | ||
const which = require('npm-which')(process.cwd()); | ||
const which = require('npm-which'); | ||
const { platform } = require('os'); | ||
const yaml = require('js-yaml'); | ||
const { lookupPaths } = require('./fs'); | ||
const debug = require('debug')('cy2'); | ||
@@ -18,6 +20,6 @@ exports.patch = async function (apiURL) { | ||
} | ||
debug('Patching cypress config file: %s', configFilePath); | ||
const doc = yaml.load(fs.readFileSync(configFilePath, 'utf8')); | ||
doc.production.api_url = apiURL; | ||
fs.writeFileSync(configFilePath, yaml.dump(doc)); | ||
@@ -29,2 +31,3 @@ }; | ||
const cliBinPath = await getCypressCLIBinPath(); | ||
debug('Running cypress from %s', cliBinPath); | ||
const child = cp.spawn(cliBinPath, [...rest], { stdio: 'inherit' }); | ||
@@ -34,2 +37,28 @@ child.on('exit', (code) => process.exit(code)); | ||
async function getConfigFilesPaths() { | ||
const stateModulePath = await getStateModulePath(); | ||
const state = require(stateModulePath); | ||
const pkgPath = state.getBinaryPkgPath(state.getBinaryDir()); | ||
debug('Cypress pkgPath: %s', pkgPath); | ||
const pkgRoot = path.dirname(pkgPath); | ||
debug('Cypress pkgRoot: %s', pkgRoot); | ||
const configFilePath = path.resolve( | ||
pkgRoot, | ||
'packages/server/config/app.yml' | ||
); | ||
const backupConfigFilePath = path.resolve( | ||
pkgRoot, | ||
'packages/server/config/_app.yml' | ||
); | ||
debug('Cypress configFilePath: %s', configFilePath); | ||
return { | ||
configFilePath, | ||
backupConfigFilePath, | ||
}; | ||
} | ||
async function getStateModulePath() { | ||
@@ -52,6 +81,12 @@ try { | ||
]; | ||
debug('Cypress state module candidates: %o', candidates); | ||
const result = lookupPaths(candidates); | ||
if (!result) { | ||
throw new Error('Cannot detect cypress'); | ||
} | ||
debug('Cypress state module detected: %s', result); | ||
return result; | ||
@@ -62,32 +97,19 @@ } catch (error) { | ||
} | ||
async function getConfigFilesPaths() { | ||
const stateModulePath = await getStateModulePath(); | ||
const state = require(stateModulePath); | ||
const pkgPath = state.getBinaryPkgPath(state.getBinaryDir()); | ||
const pkgRoot = path.dirname(pkgPath); | ||
const configFilePath = path.resolve( | ||
pkgRoot, | ||
'packages/server/config/app.yml' | ||
); | ||
const backupConfigFilePath = path.resolve( | ||
pkgRoot, | ||
'packages/server/config/_app.yml' | ||
); | ||
return { | ||
configFilePath, | ||
backupConfigFilePath, | ||
}; | ||
} | ||
function getCypressCLIBinPath() { | ||
return new Promise((resolve, reject) => { | ||
which('cypress', function (err, binaryCypress) { | ||
const location = platform() === 'win32' ? process.cwd() : __dirname; | ||
which(location)('cypress', function (err, binaryCypress) { | ||
if (err) { | ||
return reject(err.message); | ||
} | ||
return resolve(path.normalize(fs.realpathSync(binaryCypress))); | ||
debug('Cypress binary: %s', binaryCypress); | ||
const packagePath = path.normalize(fs.realpathSync(binaryCypress)); | ||
debug('Cypress normalized package path: %s', packagePath); | ||
return resolve(packagePath); | ||
}); | ||
}); | ||
} |
{ | ||
"name": "cy2", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"main": "index.js", | ||
@@ -12,6 +12,7 @@ "author": "Andrew Goldis", | ||
"scripts": { | ||
"test": "jest", | ||
"test": "jest ./__tests__/*.test.js", | ||
"release": "release-it" | ||
}, | ||
"dependencies": { | ||
"debug": "^4.3.2", | ||
"js-yaml": "^4.0.0", | ||
@@ -18,0 +19,0 @@ "npm-which": "^3.0.1" |
# cy2 | ||
![npm downloads](https://img.shields.io/npm/dw/cy2?style=flat) | ||
[![AppVeyour](https://ci.appveyor.com/api/projects/status/8i4xhejvla6rhc3m/branch/master?svg=true)](https://ci.appveyor.com/project/agoldis/cy2/branch/master) [![CircleCI](https://circleci.com/gh/sorry-cypress/cy2/tree/master.svg?style=shield)](https://circleci.com/gh/sorry-cypress/cy2/tree/master) | ||
Change cypress API URL configuration on-the-fly using environment variable `CYPRESS_API_URL`. It passes down all the CLI flags as-is, so you can just use it instead of cypress. | ||
@@ -57,3 +60,2 @@ | ||
const { run } = require('cy2'); | ||
@@ -60,0 +62,0 @@ |
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
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
9661
112
79
3
+ Addeddebug@^4.3.2
+ Addeddebug@4.4.0(transitive)
+ Addedms@2.1.3(transitive)