mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-04 13:39:52 -06:00
* WIP: add cli info command to list detected browsers * print found browsers * change to list * start work on info command calling into binary * move info command into binary * print OS info during cypress info command * add binary cache path to info command * add browser profile path * add memory * get browser profile path without partition * pick real browsers as examples * output same info as desired * better names * changed colors * add list of cached binary versions * do not put stable into name * add underlined link * conditionally show profile path, only if the folder exists * do not list cached binaries * human-friendly memory print * print env proxy vars * print CYPRESS_ env variables * use _.sample * update order * store cypress info output on CI as HTML page artifact * add percy CLI screenshots * sanitize cypress info command * store CLI snapshots in cli/visual-snapshots folder * update cli unit snapshot * add cli unit test * start e2e testing for cypress info * add test with proxy and cypress vars * make sure we call the binary * stricter start check * start unit testing modes info * test info mode browser print * add test for profile path * add cypress info command to test binary Circle job * add cypress info to test-binary-as-specific-user circle * print cypress info --dev on circle and on appveyor * update .gitignore * move error in environment load to debug
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
// call this script to sanitize output of the command
|
|
// AFTER converting ANSI escape codes into HTML tags
|
|
const arg = require('arg')
|
|
|
|
const args = arg({
|
|
'--type': String,
|
|
})
|
|
|
|
const sanitizeCliInfo = () => {
|
|
const chromiumVersion = /- Version: (<.+>)(\d{2,3}.\d\.\d+.\d+)(<.+>)/g
|
|
const firefoxVersion = /- Version: (<.+>)(\d{2,3}.\d\.\d+|\d+\.[0-9a-z])(<.+>)+/g
|
|
const browserArgument = /--browser (\w+:?\w+)/g
|
|
// there is only a single line with memory usage
|
|
const systemMemory = /System Memory: (<.+>)([\w.]+ \w+)(<.+>) free (<.+>)([\w.]+ \w+)(<.+>)/
|
|
|
|
const replaceChromiumVersion = (match, openTag, version, closeTag) => {
|
|
return `- Version: ${openTag}***chromium version***${closeTag}`
|
|
}
|
|
|
|
const replaceFirefoxVersion = (match, openTag, version, closeTag) => {
|
|
return `- Version: ${openTag}***firefox version***${closeTag}`
|
|
}
|
|
|
|
const replaceBrowserArgument = (match, browserName) => {
|
|
return '--browser ***name:channel***'
|
|
}
|
|
|
|
const replaceSystemMemory = (match, tag1, total, tag2, tag3, free, tag4) => {
|
|
return `System Memory: ${tag1}***total memory***${tag2} free ${tag3}***free memory***${tag4}`
|
|
}
|
|
|
|
const sanitize = (chunk) => {
|
|
return chunk.replace(chromiumVersion, replaceChromiumVersion)
|
|
.replace(firefoxVersion, replaceFirefoxVersion)
|
|
.replace(browserArgument, replaceBrowserArgument)
|
|
.replace(systemMemory, replaceSystemMemory)
|
|
}
|
|
|
|
process.stdin.setEncoding('utf8')
|
|
process.stdin.on('data', function (chunk) {
|
|
return process.stdout.write(sanitize(chunk))
|
|
})
|
|
}
|
|
|
|
switch (args['--type']) {
|
|
case 'cli-info':
|
|
sanitizeCliInfo()
|
|
break
|
|
default:
|
|
throw new Error(`Unknown STDOUT type to sanitize "${args['--type']}"`)
|
|
}
|