diff --git a/lib/commands/fullscans/list.js b/lib/commands/fullscans/list.js index e0618949..4772dfea 100644 --- a/lib/commands/fullscans/list.js +++ b/lib/commands/fullscans/list.js @@ -1,12 +1,13 @@ /* eslint-disable no-console */ import chalk from 'chalk' +// @ts-ignore +import chalkTable from 'chalk-table' import meow from 'meow' import ora from 'ora' import { outputFlags } from '../../flags/index.js' import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js' -import chalkTable from '../../utils/chalk-table.js' import { InputError } from '../../utils/errors.js' import { prepareFlags } from '../../utils/flags.js' import { printFlagList } from '../../utils/formatting.js' diff --git a/lib/utils/chalk-table.js b/lib/utils/chalk-table.js index 10d80c94..e051e4c2 100644 --- a/lib/utils/chalk-table.js +++ b/lib/utils/chalk-table.js @@ -1,102 +1,101 @@ -// @ts-nocheck -// Inspired by https://www.npmjs.com/package/chalk-table -import chalk from 'chalk' -import stripAnsi from 'strip-ansi' +// // Inspired by https://www.npmjs.com/package/chalk-table +// import chalk from 'chalk' +// import stripAnsi from 'strip-ansi' -export default (options, data) => { - const pad = (text, length) => { - if (typeof text === 'undefined') { - text = '' - } +// export default (/** @type {{columns: []}} */ options, data) => { +// const pad = (text, length) => { +// if (typeof text === 'undefined') { +// text = '' +// } - return ( - '' + - text + - new Array(Math.max(length - stripAnsi('' + text).length + 1, 0)).join(' ') - ) - } +// return ( +// '' + +// text + +// new Array(Math.max(length - stripAnsi('' + text).length + 1, 0)).join(' ') +// ) +// } - if (typeof options === 'object' && Array.isArray(options)) { - const tmp = data - data = options - options = tmp - } +// if (typeof options === 'object' && Array.isArray(options)) { +// const tmp = data +// data = options +// options = tmp +// } - if (!options) { - options = {} - } +// if (!options) { +// options = {} +// } - if (!options.intersectionCharacter) { - options.intersectionCharacter = '+' - } +// if (!options.intersectionCharacter) { +// options.intersectionCharacter = '+' +// } - let columns - if (options.columns) { - columns = options.columns - } else { - columns = [] - data.forEach(e => - Object.keys(e) - .filter(k => columns.indexOf(k) === -1) - .forEach(k => { - columns.push(k) - }) - ) - } +// let columns +// if (options.columns) { +// columns = options.columns +// } else { +// columns = [] +// data.forEach(e => +// Object.keys(e) +// .filter(k => columns.indexOf(k) === -1) +// .forEach(k => { +// columns.push(k) +// }) +// ) +// } - columns = columns.map(e => { - if (typeof e === 'string') { - e = { - name: e, - field: e - } - } +// columns = columns.map(e => { +// if (typeof e === 'string') { +// e = { +// name: e, +// field: e +// } +// } - e.name = chalk.bold(e.name) - e.width = stripAnsi(e.name).length +// e.name = chalk.bold(e.name) +// e.width = stripAnsi(e.name).length - return e - }) +// return e +// }) - data.forEach(e => - columns.forEach(column => { - if (typeof e[column.field] === 'undefined') { - return - } +// data.forEach(e => +// columns.forEach(column => { +// if (typeof e[column.field] === 'undefined') { +// return +// } - column.width = Math.max( - column.width, - ('' + stripAnsi(e[column.field])).length - ) - }) - ) +// column.width = Math.max( +// column.width, +// ('' + stripAnsi(e[column.field])).length +// ) +// }) +// ) - const output = [] +// const output = [] - const separator = [''] - .concat(columns.map(e => new Array(e.width + 1).join('-'))) - .concat(['']) - .join('-' + options.intersectionCharacter + '-') +// const separator = [''] +// .concat(columns.map(e => new Array(e.width + 1).join('-'))) +// .concat(['']) +// .join('-' + options.intersectionCharacter + '-') - output.push(separator) - output.push( - [''] - .concat(columns.map(e => pad(e.name, e.width))) - .concat(['']) - .join(' | ') - ) - output.push(separator) - data.forEach(row => { - output.push( - [''] - .concat(columns.map(column => pad(row[column.field], column.width))) - .concat(['']) - .join(' | ') - ) - }) - output.push(separator) +// output.push(separator) +// output.push( +// [''] +// .concat(columns.map(e => pad(e.name, e.width))) +// .concat(['']) +// .join(' | ') +// ) +// output.push(separator) +// data.forEach(row => { +// output.push( +// [''] +// .concat(columns.map(column => pad(row[column.field], column.width))) +// .concat(['']) +// .join(' | ') +// ) +// }) +// output.push(separator) - return ( - output.map(e => e.replace(/^[ -]/, '').replace(/[ -]$/, '')).join('\n') - ) -} +// return ( +// output.map(e => e.replace(/^[ -]/, '').replace(/[ -]$/, '')).join('\n') +// ) +// } diff --git a/package.json b/package.json index e33a39d5..bac0adc7 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "check:installed-check": "installed-check -i eslint-plugin-jsdoc", "check:lint": "eslint --report-unused-disable-directives .", "check:tsc": "tsc", - "check:type-coverage": "type-coverage --detail --strict --at-least 95 --ignore-files 'test/*'", + "check:type-coverage": "type-coverage --detail --strict --at-least 90 --ignore-files 'test/*'", "check": "run-p -c --aggregate-output check:*", "prepare": "husky install", "test:unit": "c8 --reporter=lcov --reporter text node --test", @@ -85,6 +85,7 @@ "@socketsecurity/config": "^2.0.0", "@socketsecurity/sdk": "^0.9.0", "chalk": "^5.1.2", + "chalk-table": "^1.0.2", "globby": "^13.1.3", "hpagent": "^1.2.0", "ignore": "^5.2.1", @@ -96,7 +97,6 @@ "ora": "^7.0.1", "pony-cause": "^2.1.8", "prompts": "^2.4.2", - "strip-ansi": "^7.1.0", "terminal-link": "^3.0.0", "update-notifier": "^6.0.2", "which": "^3.0.0"