Skip to content

Commit

Permalink
upgrade dependencies: babel
Browse files Browse the repository at this point in the history
  • Loading branch information
charlierudolph committed Dec 21, 2018
1 parent c78d4dc commit 31e51ff
Show file tree
Hide file tree
Showing 17 changed files with 1,155 additions and 1,198 deletions.
37 changes: 8 additions & 29 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
{
"plugins": [
"check-es2015-constants",
"external-helpers",
"transform-es2015-arrow-functions",
"transform-es2015-block-scoped-functions",
"transform-es2015-block-scoping",
"transform-es2015-classes",
"transform-es2015-computed-properties",
"transform-es2015-destructuring",
"transform-es2015-duplicate-keys",
"transform-es2015-for-of",
"transform-es2015-function-name",
"transform-es2015-literals",
"transform-es2015-modules-commonjs",
"transform-es2015-object-super",
"transform-es2015-parameters",
"transform-es2015-shorthand-properties",
"transform-es2015-spread",
"transform-es2015-sticky-regex",
"transform-es2015-template-literals",
"transform-es2015-typeof-symbol",
"transform-es2015-unicode-regex",
"transform-function-bind",
"transform-object-rest-spread",
["transform-async-to-module-method", {"module": "bluebird", "method": "coroutine"}],
["transform-runtime", {"polyfill": false, "regenerator": false}]
"@babel/plugin-proposal-function-bind",
"@babel/plugin-transform-shorthand-properties"
],
"presets": [
["@babel/preset-env", {"targets": "maintained node versions"}]
],
"env": {
"test_coverage": {
Expand All @@ -33,11 +13,10 @@
]
},
"browser": {
"plugins": [
"transform-regenerator",
["transform-runtime", {"polyfill": false, "regenerator": true}]
"presets": [
["@babel/preset-env", {"targets": "last 2 versions", "useBuiltIns": "usage"}]
]
}
},
"sourceMaps": "inline"
"sourceMaps": true
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ coverage/
dist/browser-example.js
lib/
node_modules
tmp/
usage.txt
yarn-error.log
2 changes: 1 addition & 1 deletion cucumber.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var common = [
'--require-module babel-register',
'--require-module @babel/register',
`--format ${
process.env.CI || !process.stdout.isTTY ? 'progress' : 'progress-bar'
}`,
Expand Down
17 changes: 7 additions & 10 deletions dependency-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@ ignoreErrors:
shouldBeDependency: []
shouldBeDevDependency: []
unused:
- '@babel/core'
- '@babel/polyfill'
- '@babel/plugin-proposal-function-bind' # .babelrc
- '@babel/preset-env' # .babelrc
- '@babel/register' # test/mocha.opts
- babel-eslint # .eslintrc.yml - plugins
- babel-plugin-external-helpers # .babelrc
- babel-plugin-istanbul # .babelrc
- babel-plugin-transform-async-to-module-method # .babelrc
- babel-plugin-transform-function-bind # .babelrc
- babel-plugin-transform-object-rest-spread # .babelrc
- babel-plugin-transform-promise-to-bluebird # .babelrc
- babel-plugin-transform-regenerator # .babelrc
- babel-plugin-transform-runtime # .babelrc
- babel-preset-es2015 # .babelrc
- babel-register # test/mocha.opts
- babelify # package.json - scripts - build-browser-example / build-release
- coffee-script # features/compiler.feature
- coveralls # .travis.yml
Expand All @@ -56,10 +52,11 @@ requiredModules:
- 'dist/**/*'
- 'lib/**/*'
- 'node_modules/**/*'
- 'tmp/**/*'
root: '**/*.js'
stripLoaders: false
transpilers:
- extension: .js
fnName: transform
module: babel-core # 6.17.0
module: '@babel/core' # 7.2.3
resultKey: code
4 changes: 2 additions & 2 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ansiHTML from 'ansi-html'

let featureEditor, stepDefinitionsEditor, $output

function runFeature() {
async function runFeature() {
$output.empty()
$('a[href="#output-tab"]').tab('show')

Expand All @@ -23,7 +23,7 @@ function runFeature() {

Cucumber.supportCodeLibraryBuilder.reset('')
new Function(stepDefinitionsEditor.getValue())() // eslint-disable-line no-new-func
const supportCodeLibrary = Cucumber.supportCodeLibraryBuilder.finalize()
const supportCodeLibrary = await Cucumber.supportCodeLibraryBuilder.finalize()

const formatterOptions = {
colorsEnabled: true,
Expand Down
2 changes: 1 addition & 1 deletion features/profiles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: default command line arguments
"""
And a file named "cucumber.js" with:
"""
var common = '--require-module babel-register ';
var common = '--require-module @babel/register ';
module.exports = {
'default': common + '--format summary',
Expand Down
7 changes: 5 additions & 2 deletions features/step_definitions/fixture_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import path from 'path'
Then('the output matches the fixture {string}', async function(filePath) {
const fixturePath = path.join(__dirname, '..', 'fixtures', filePath)
const expected = await fs.readFile(fixturePath, 'utf8')
const normalizedActual = normalizeEventProtocolOutput(this.lastRun.output)
const normalizedExpected = normalizeEventProtocolOutput(expected)
const normalizedActual = normalizeEventProtocolOutput(
this.lastRun.output,
this.tmpDir
)
const normalizedExpected = normalizeEventProtocolOutput(expected, this.tmpDir)
expect(normalizedActual).to.eql(normalizedExpected)
})
28 changes: 21 additions & 7 deletions features/support/event_protocol_output_helpers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import path from 'path'

export function normalizeEventProtocolOutput(str) {
return str
.replace(/"duration":\d*/g, '"duration":0')
.replace(
/"uri":"([^"]*)"/g,
(match, uri) => `"uri":"${path.normalize(uri)}"`
)
export function normalizeEventProtocolOutput(str, cwd) {
return (
str
.replace(/"duration":\d*/g, '"duration":0')
.replace(
/"uri":"([^"]*)"/g,
(match, uri) => `"uri":"${path.normalize(uri)}"`
)
// Converting windows stack trace
// C:\\project\\path\\features\\support/code.js
// to
// features/support/code.js
.replace(/"exception":"([^"]*)"/g, (match, exception) => {
const updatedException = exception
.replace(/\\\\/g, '\\')
.replace(cwd, '')
.replace(/\\/g, '/')
.replace('/features', 'features')
return `"exception":"${updatedException}"`
})
)
}
27 changes: 7 additions & 20 deletions features/support/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,20 @@ Before('@spawn', function() {
this.spawn = true
})

Before(function() {
const tmpObject = tmp.dirSync({ unsafeCleanup: true })
this.tmpDir = fs.realpathSync(tmpObject.name)
Before(function({ sourceLocation: { uri, line } }) {
this.tmpDir = path.join(projectPath, 'tmp', `${path.basename(uri)}_${line}`)

fsExtra.removeSync(this.tmpDir)

const tmpDirProfilePath = path.join(this.tmpDir, 'cucumber.js')
const profileContent =
'module.exports = {default: "--require-module babel-register"}'
fs.writeFileSync(tmpDirProfilePath, profileContent)

const tmpDirBabelRcPath = path.join(this.tmpDir, '.babelrc')
const profileBabelRcPath = path.join(projectPath, '.babelrc')
fsExtra.createSymlinkSync(profileBabelRcPath, tmpDirBabelRcPath)
'module.exports = {default: "--require-module @babel/register"}'
fsExtra.outputFileSync(tmpDirProfilePath, profileContent)

const tmpDirNodeModulesPath = path.join(this.tmpDir, 'node_modules')
moduleNames.forEach(moduleName => {
const tmpDirNodeModulePath = path.join(tmpDirNodeModulesPath, moduleName)
const projectNodeModulePath = path.join(
projectPath,
'node_modules',
moduleName
)
fsExtra.createSymlinkSync(projectNodeModulePath, tmpDirNodeModulePath)
})

const tmpDirCucumberPath = path.join(tmpDirNodeModulesPath, 'cucumber')
fsExtra.createSymlinkSync(projectPath, tmpDirCucumberPath)
this.localExecutablePath = path.join(tmpDirCucumberPath, 'bin', 'cucumber-js')
this.localExecutablePath = path.join(projectPath, 'bin', 'cucumber-js')
})

Before('@global-install', function() {
Expand Down
23 changes: 9 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@
"node": ">=0.10"
},
"dependencies": {
"@babel/polyfill": "^7.2.3",
"assertion-error-formatter": "^2.0.1",
"babel-runtime": "^6.11.6",
"bluebird": "^3.4.1",
"cli-table3": "^0.5.1",
"colors": "^1.1.2",
Expand Down Expand Up @@ -177,19 +177,15 @@
"verror": "^1.9.0"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-function-bind": "^7.2.0",
"@babel/preset-env": "^7.2.3",
"@babel/register": "^7.0.0",
"ansi-html": "^0.0.7",
"babel-cli": "^6.10.1",
"babel-eslint": "^8.0.1",
"babel-plugin-external-helpers": "^6.18.0",
"babel-plugin-istanbul": "^4.1.3",
"babel-plugin-transform-async-to-module-method": "^6.16.0",
"babel-plugin-transform-function-bind": "^6.8.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-plugin-transform-promise-to-bluebird": "^1.1.1",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-register": "^6.9.0",
"babelify": "^8.0.0",
"babel-eslint": "^10.0.1",
"babel-plugin-istanbul": "^5.1.0",
"babelify": "^10.0.0",
"browserify": "16.2.2",
"chai": "^4.0.1",
"coffee-script": "^1.10.0",
Expand All @@ -210,7 +206,6 @@
"mustache": "^2.3.0",
"nyc": "^12.0.2",
"prettier": "^1.5.2",
"regenerator-runtime": "^0.11.0",
"serve-static": "^1.10.0",
"sinon": "^6.0.0",
"sinon-chai": "^3.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash'
import { formatLocation } from '../formatter/helpers'
import Promise from 'bluebird'
import StackTraceFilter from './stack_trace_filter'
import StackTraceFilter from '../stack_trace_filter'
import Status from '../status'
import TestCaseRunner from './test_case_runner'
import UserCodeRunner from '../user_code_runner'
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/parallel/slave.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import commandTypes from './command_types'
import EventEmitter from 'events'
import Promise from 'bluebird'
import serializeError from 'serialize-error'
import StackTraceFilter from '../stack_trace_filter'
import StackTraceFilter from '../../stack_trace_filter'
import supportCodeLibraryBuilder from '../../support_code_library_builder'
import TestCaseRunner from '../test_case_runner'
import UserCodeRunner from '../../user_code_runner'
Expand Down
15 changes: 10 additions & 5 deletions src/runtime/stack_trace_filter.js → src/stack_trace_filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import _ from 'lodash'
import stackChain from 'stack-chain'
import path from 'path'

export default class StackTraceFilter {
constructor() {
this.cucumberPath = path.join(__dirname, '..', '..')
}
const projectRootPath = path.join(__dirname, '..')
const projectChildDirs = ['src', 'lib', 'node_modules']

export function isFileNameInCucumber(fileName) {
return _.some(projectChildDirs, dir =>
_.startsWith(fileName, path.join(projectRootPath, dir))
)
}

export default class StackTraceFilter {
filter() {
this.currentFilter = stackChain.filter.attach((_err, frames) => {
if (this.isErrorInCucumber(frames)) {
Expand All @@ -29,7 +34,7 @@ export default class StackTraceFilter {

isFrameInCucumber(frame) {
const fileName = frame.getFileName() || ''
return _.startsWith(fileName, this.cucumberPath)
return isFileNameInCucumber(fileName)
}

isFrameInNode(frame) {
Expand Down
11 changes: 2 additions & 9 deletions src/support_code_library_builder/build_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from 'cucumber-expressions'
import path from 'path'
import StackTrace from 'stacktrace-js'
import { isFileNameInCucumber } from '../stack_trace_filter'
import StepDefinition from '../models/step_definition'
import TestCaseHookDefinition from '../models/test_case_hook_definition'
import TestRunHookDefinition from '../models/test_run_hook_definition'
Expand Down Expand Up @@ -87,20 +88,12 @@ export function buildStepDefinitionFromConfig({
return new StepDefinition({ code, line, options, uri, pattern, expression })
}

const projectPath = path.join(__dirname, '..', '..')
const projectSrcPath = path.join(projectPath, 'src')
const projectLibPath = path.join(projectPath, 'lib')

function getDefinitionLineAndUri(cwd) {
let line = 'unknown'
let uri = 'unknown'
const stackframes = StackTrace.getSync()
const stackframe = _.find(stackframes, frame => {
const filename = frame.getFileName()
return (
!_.includes(filename, projectSrcPath) &&
!_.includes(filename, projectLibPath)
)
return !isFileNameInCucumber(frame.getFileName())
})
if (stackframe) {
line = stackframe.getLineNumber()
Expand Down
2 changes: 1 addition & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
--fullTrace
--recursive
--reporter dot
--require babel-register
--require @babel/register
test/test_helper.js
1 change: 0 additions & 1 deletion test/test_helper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'regenerator-runtime/runtime'
import chai from 'chai'
import sinonChai from 'sinon-chai'

Expand Down
Loading

0 comments on commit 31e51ff

Please sign in to comment.