mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-25 10:30:39 -06:00
chore: Vendor @cypress/listr-verbose-renderer (#16855)
This commit is contained in:
committed by
GitHub
parent
400567e8b0
commit
39e1786211
72
cli/lib/VerboseRenderer.js
Normal file
72
cli/lib/VerboseRenderer.js
Normal file
@@ -0,0 +1,72 @@
|
||||
// Vendored from @cypress/listr-verbose-renderer
|
||||
const figures = require('figures')
|
||||
const cliCursor = require('cli-cursor')
|
||||
const chalk = require('chalk')
|
||||
const dayjs = require('dayjs')
|
||||
|
||||
const formattedLog = (options, output) => {
|
||||
const timestamp = dayjs().format(options.dateFormat)
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`${chalk.dim(`[${timestamp}]`) } ${output}`)
|
||||
}
|
||||
|
||||
const renderHelper = (task, event, options) => {
|
||||
const log = formattedLog.bind(undefined, options)
|
||||
|
||||
if (event.type === 'STATE') {
|
||||
const message = task.isPending() ? 'started' : task.state
|
||||
|
||||
log(`${task.title} [${message}]`)
|
||||
|
||||
if (task.isSkipped() && task.output) {
|
||||
log(`${figures.arrowRight} ${task.output}`)
|
||||
}
|
||||
} else if (event.type === 'TITLE') {
|
||||
log(`${task.title} [title changed]`)
|
||||
}
|
||||
}
|
||||
|
||||
const render = (tasks, options) => {
|
||||
for (const task of tasks) {
|
||||
task.subscribe(
|
||||
(event) => {
|
||||
if (event.type === 'SUBTASKS') {
|
||||
render(task.subtasks, options)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
renderHelper(task, event, options)
|
||||
},
|
||||
(err) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(err)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class VerboseRenderer {
|
||||
constructor (tasks, options) {
|
||||
this._tasks = tasks
|
||||
this._options = Object.assign({
|
||||
dateFormat: 'HH:mm:ss',
|
||||
}, options)
|
||||
}
|
||||
|
||||
static get nonTTY () {
|
||||
return true
|
||||
}
|
||||
|
||||
render () {
|
||||
cliCursor.hide()
|
||||
render(this._tasks, this._options)
|
||||
}
|
||||
|
||||
end () {
|
||||
cliCursor.show()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = VerboseRenderer
|
||||
@@ -5,7 +5,6 @@ const path = require('path')
|
||||
const chalk = require('chalk')
|
||||
const debug = require('debug')('cypress:cli')
|
||||
const { Listr } = require('listr2')
|
||||
const verbose = require('@cypress/listr-verbose-renderer')
|
||||
const Promise = require('bluebird')
|
||||
const logSymbols = require('log-symbols')
|
||||
const { stripIndent } = require('common-tags')
|
||||
@@ -16,6 +15,7 @@ const state = require('./state')
|
||||
const unzip = require('./unzip')
|
||||
const logger = require('../logger')
|
||||
const { throwFormErrorText, errors } = require('../errors')
|
||||
const verbose = require('../VerboseRenderer')
|
||||
|
||||
const getNpmArgv = () => {
|
||||
const json = process.env.npm_config_argv
|
||||
|
||||
@@ -2,13 +2,13 @@ const _ = require('lodash')
|
||||
const chalk = require('chalk')
|
||||
const { Listr } = require('listr2')
|
||||
const debug = require('debug')('cypress:cli')
|
||||
const verbose = require('@cypress/listr-verbose-renderer')
|
||||
const { stripIndent } = require('common-tags')
|
||||
const Promise = require('bluebird')
|
||||
const logSymbols = require('log-symbols')
|
||||
const path = require('path')
|
||||
const os = require('os')
|
||||
|
||||
const verbose = require('../VerboseRenderer')
|
||||
const { throwFormErrorText, errors } = require('../errors')
|
||||
const util = require('../util')
|
||||
const logger = require('../logger')
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
"cachedir": "^2.3.0",
|
||||
"chalk": "^4.1.0",
|
||||
"check-more-types": "^2.24.0",
|
||||
"cli-cursor": "^3.1.0",
|
||||
"cli-table3": "~0.6.0",
|
||||
"commander": "^5.1.0",
|
||||
"common-tags": "^1.8.0",
|
||||
@@ -41,6 +42,7 @@
|
||||
"execa": "4.1.0",
|
||||
"executable": "^4.1.1",
|
||||
"extract-zip": "2.0.1",
|
||||
"figures": "^3.2.0",
|
||||
"fs-extra": "^9.1.0",
|
||||
"getos": "^3.2.1",
|
||||
"is-ci": "^3.0.0",
|
||||
|
||||
Reference in New Issue
Block a user