Skip to content

Commit

Permalink
server decaf cleanup
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
flotwig committed Jun 4, 2020
1 parent e7d1f31 commit fe78574
Show file tree
Hide file tree
Showing 48 changed files with 116 additions and 546 deletions.
2 changes: 1 addition & 1 deletion packages/server/__snapshots__/8_reporters_spec.coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The error we received was:
Cannot find module '/foo/bar/.projects/e2e/node_modules/module-does-not-exist'
Require stack:
- lib/reporter.coffee
- lib/reporter.js
- lib/project.js
- lib/modes/run.js
- lib/modes/index.js
Expand Down
24 changes: 5 additions & 19 deletions packages/server/lib/api.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,21 @@
/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
let intervals
const _ = require('lodash')
const os = require('os')
const debug = require('debug')('cypress:server:api')
const request = require('@cypress/request-promise')
const errors = require('@cypress/request-promise/errors')
const Promise = require('bluebird')
const humanInterval = require('human-interval')
const {
agent,
} = require('@packages/network')
const { agent } = require('@packages/network')
const pkg = require('@packages/root')
const machineId = require('./util/machine_id')
const routes = require('./util/routes')
const system = require('./util/system')
const cache = require('./cache')

const THIRTY_SECONDS = humanInterval('30 seconds')
const SIXTY_SECONDS = humanInterval('60 seconds')
const TWO_MINUTES = humanInterval('2 minutes')

let intervals

let DELAYS = [
THIRTY_SECONDS,
SIXTY_SECONDS,
Expand Down Expand Up @@ -122,8 +108,8 @@ const tagError = function (err) {
// retry on timeouts, 5xx errors, or any error without a status code
const isRetriableError = (err) => {
return (err instanceof Promise.TimeoutError) ||
(500 <= err.statusCode && err.statusCode < 600) ||
(err.statusCode == null)
(500 <= err.statusCode && err.statusCode < 600) ||
(err.statusCode == null)
}

module.exports = {
Expand Down
11 changes: 0 additions & 11 deletions packages/server/lib/cache.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const _ = require('lodash')
const path = require('path')
const Promise = require('bluebird')
const fs = require('./util/fs')
const appData = require('./util/app_data')
Expand Down
26 changes: 5 additions & 21 deletions packages/server/lib/capture.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
/* eslint-disable
prefer-rest-params,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const _write = process.stdout.write
const _log = process.log

Expand All @@ -18,19 +8,11 @@ const restore = function () {
}

const stdout = function () {
// always restore right when we start capturing
// restore()

const logs = []

// lazily backup write to enable
// injection
const {
write,
} = process.stdout
const {
log,
} = process
// lazily backup write to enable injection
const { write } = process.stdout
const { log } = process

// electron adds a new process.log
// method for windows instead of process.stdout.write
Expand All @@ -39,13 +21,15 @@ const stdout = function () {
process.log = function (str) {
logs.push(str)

// eslint-disable-next-line prefer-rest-params
return log.apply(this, arguments)
}
}

process.stdout.write = function (str) {
logs.push(str)

// eslint-disable-next-line prefer-rest-params
return write.apply(this, arguments)
}

Expand Down
32 changes: 8 additions & 24 deletions packages/server/lib/config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
/* eslint-disable
default-case,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS104: Avoid inline assignments
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const _ = require('lodash')
const R = require('ramda')
const la = require('lazy-ass')
const path = require('path')
const check = require('check-more-types')
const Promise = require('bluebird')
const deepDiff = require('return-deep-diff')
const errors = require('./errors')
Expand All @@ -42,7 +27,6 @@ const CYPRESS_SPECIAL_ENV_VARS = [

const dashesOrUnderscoresRe = /^(_-)+/
const oneOrMoreSpacesRe = /\s+/
const everythingAfterFirstEqualRe = /=(.+)/

const toWords = (str) => {
return str.trim().split(oneOrMoreSpacesRe)
Expand Down Expand Up @@ -257,6 +241,7 @@ const validateNoBreakingConfig = (cfg) => {
return errors.throw('RENAMED_CONFIG_OPTION', key, 'trashAssetsBeforeRuns')
case 'videoRecording':
return errors.throw('RENAMED_CONFIG_OPTION', key, 'video')
default:
}
}
})
Expand Down Expand Up @@ -312,7 +297,7 @@ const utils = {
// null - if there is an error finding the file
discoverModuleFile (options) {
debug('discover module file %o', options)
const { filename, projectRoot, isDefault } = options
const { filename, isDefault } = options

if (!isDefault) {
// they have it explicitly set, so it should be there
Expand Down Expand Up @@ -524,11 +509,12 @@ module.exports = {
})
},

updateWithPluginValues (cfg, overrides = {}) {
// diff the overrides with cfg
// including nested objects (env)
debug('starting config %o', cfg)
debug('overrides %o', overrides)
updateWithPluginValues (cfg, overrides) {
if (!overrides) {
overrides = {}
}

debug('updateWithPluginValues %o', { cfg, overrides })

// make sure every option returned from the plugins file
// passes our validation functions
Expand Down Expand Up @@ -789,8 +775,6 @@ module.exports = {
})
.then((result) => {
if (result === null) {
const configFile = obj.configFile || CONFIG_DEFAULTS.configFile

return errors.throw('PLUGINS_FILE_ERROR', path.resolve(obj.projectRoot, pluginsFile))
}

Expand Down
7 changes: 0 additions & 7 deletions packages/server/lib/controllers/client.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const debug = require('debug')('cypress:server:controllers:client')
const socketIo = require('@packages/socket')

Expand Down
16 changes: 2 additions & 14 deletions packages/server/lib/controllers/files.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
/* eslint-disable
brace-style,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const _ = require('lodash')
const R = require('ramda')
const path = require('path')
Expand All @@ -17,7 +6,6 @@ const cwd = require('../cwd')
const glob = require('../util/glob')
const specsUtil = require('../util/specs')
const pathHelpers = require('../util/path_helpers')
const CacheBuster = require('../util/cache_buster')
const debug = require('debug')('cypress:server:controllers')
const { escapeFilenameInUrl } = require('../util/escape_filename')

Expand Down Expand Up @@ -87,8 +75,8 @@ module.exports = {
return true
}).then(R.tap((specs) => {
return debug('filtered __all specs %o', specs)
})).map((spec) => // grab the name of each
{
})).map((spec) => {
// grab the name of each
return spec.absolute
}).map(convertSpecPath)
}
Expand Down
11 changes: 0 additions & 11 deletions packages/server/lib/controllers/reporter.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const _ = require('lodash')
const send = require('send')
const reporter = require('@packages/reporter/lib/resolve-dist')

Expand Down
11 changes: 0 additions & 11 deletions packages/server/lib/controllers/runner.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const _ = require('lodash')
const cache = require('../cache')
const send = require('send')
const os = require('os')
const fs = require('../util/fs')
Expand Down
7 changes: 0 additions & 7 deletions packages/server/lib/controllers/static.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const send = require('send')
const staticPkg = require('@packages/static')

Expand Down
17 changes: 2 additions & 15 deletions packages/server/lib/controllers/xhrs.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
/* eslint-disable
brace-style,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS104: Avoid inline assignments
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const _ = require('lodash')
const mime = require('mime')
const Promise = require('bluebird')
Expand Down Expand Up @@ -124,9 +112,8 @@ module.exports = {
},

parseContentType (response) {
const ret = (type) => //+ "; charset=utf-8"
{
return mime.getType(type)
const ret = (type) => {
return mime.getType(type) //+ "; charset=utf-8"
}

if (isValidJSON(response)) {
Expand Down
8 changes: 0 additions & 8 deletions packages/server/lib/cwd.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const path = require('path')

// helper for resolving to the current working directory
// since electron does not play nice with process.cwd()
// this function should always return path.dirname('package.json')

const appPath = (function () {
// if lib is our basename then we haven't
// been concatted or moved and we need to
Expand Down
21 changes: 5 additions & 16 deletions packages/server/lib/environment.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
require('./util/fs')

const os = require('os')
//
// NOTE
//
// by loading "./cwd" we are changing the current working directory

// NOTE: by loading "./cwd" we are changing the current working directory
// to the "packages/server" folder
const cwd = require('./cwd')
require('./cwd')

const Promise = require('bluebird')
const debug = require('debug')('cypress:server')

Expand Down Expand Up @@ -48,7 +37,7 @@ if (env === 'development') {

Promise.config(config)

// note: we print error in development mode only
// NOTE: errors are printed in development mode only
try {
// i wish we didn't have to do this but we have to append
// these command line switches immediately
Expand Down
Loading

0 comments on commit fe78574

Please sign in to comment.