mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-25 10:19:30 -05:00
3481d1acaf
* migrate cli scripts to TypeScript * convert all javascript source files in the CLI to TypeScript rebase into first * chore: refactor all tests to TypeScript rebase into second * add npmignore for cli for typescript files * update build process * fix publically available exports * Fix cy-in-cy tests * add ts-expect-error to failing files * fix projectConfigIpc failures as there are now multiple installs of tsx * fix after-pack hook * fix binary script * chore: update publish binary to account for CLI being an ESModule compiled down to CommonJS * does this work? * fix the verify spec by making the listr2 renderer silent as it behaves differently since the refactor and is printing non deterministic outputs into our tests that do not have a large impact on the area we are testing and mostly served to actually test the renders of the listr2 framework itself * empty commit * additional refactor to code to remove strange any typing and exporting * bump cache and build binaries * fix CLI exports to keep backwards compatibility * fix unit-tests * turn on mac jobs * fix group name rename in CLI * remove babel deps from cli and explicitly install typescript * address feedback from code review * dont just falsy check results and instead explicitly check for null or undefined * add ts-expect-error * additional pass on cleaning up dynamic require / import from global lib references * annotate ts-expect-errors with reason for why error is expected * add rest of ts-expect-error comments * removing hardcoded branch to publish binary chore/migrate_cli_to_typescript
76 lines
1.6 KiB
TypeScript
76 lines
1.6 KiB
TypeScript
// Vendored from @cypress/listr-verbose-renderer
|
|
import figures from 'figures'
|
|
import cliCursor from 'cli-cursor'
|
|
import chalk from 'chalk'
|
|
import dayjs from 'dayjs'
|
|
|
|
const formattedLog = (options: any, output: string): void => {
|
|
const timestamp = dayjs().format(options.dateFormat)
|
|
|
|
// eslint-disable-next-line no-console
|
|
console.log(`${chalk.dim(`[${timestamp}]`)} ${output}`)
|
|
}
|
|
|
|
const renderHelper = (task: any, event: any, options: any): void => {
|
|
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: any[], options: any): void => {
|
|
for (const task of tasks) {
|
|
task.subscribe(
|
|
(event: any) => {
|
|
if (event.type === 'SUBTASKS') {
|
|
render(task.subtasks, options)
|
|
|
|
return
|
|
}
|
|
|
|
renderHelper(task, event, options)
|
|
},
|
|
(err: any) => {
|
|
// eslint-disable-next-line no-console
|
|
console.log(err)
|
|
},
|
|
)
|
|
}
|
|
}
|
|
|
|
class VerboseRenderer {
|
|
private _tasks: any[]
|
|
private _options: any
|
|
|
|
constructor (tasks: any[], options: any) {
|
|
this._tasks = tasks
|
|
this._options = Object.assign({
|
|
dateFormat: 'HH:mm:ss',
|
|
}, options)
|
|
}
|
|
|
|
static get nonTTY (): boolean {
|
|
return true
|
|
}
|
|
|
|
render (): void {
|
|
cliCursor.hide()
|
|
render(this._tasks, this._options)
|
|
}
|
|
|
|
end (): void {
|
|
cliCursor.show()
|
|
}
|
|
}
|
|
|
|
export default VerboseRenderer
|