Skip to content

Commit f2bc285

Browse files
committed
Cherry-pick from bless and blessed-contrib
1 parent dfc5820 commit f2bc285

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/commands/analytics.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import fs from 'node:fs/promises'
22

3-
import blessed from 'blessed'
43
// @ts-ignore
5-
import contrib from 'blessed-contrib'
4+
import ScreenWidget from 'blessed/lib/widgets/screen'
5+
// @ts-ignore
6+
import BarChart from 'blessed-contrib/lib/widget/charts/bar'
7+
// @ts-ignore
8+
import GridLayout from 'blessed-contrib/lib/layout/grid'
9+
// @ts-ignore
10+
import LineChart from 'blessed-contrib/lib/widget/charts/line'
611
import chalk from 'chalk'
712
import meow from 'meow'
813
import ora from 'ora'
@@ -137,7 +142,7 @@ function setupCommand(
137142
if (scope === 'repo' && !repo) {
138143
showHelp = true
139144
console.error(
140-
`${chalk.bgRed.white('Input error')}: Please provide a repository name when using the repository scope. \n`
145+
`${chalk.bgRed.white('Input error')}: Please provide a repository name when using the repository scope.`
141146
)
142147
}
143148
if (showHelp) {
@@ -372,8 +377,8 @@ async function fetchRepoAnalyticsData(
372377
}
373378

374379
const displayAnalyticsScreen = (data: any) => {
375-
const screen = blessed.screen()
376-
const grid = new contrib.grid({ rows: 5, cols: 4, screen })
380+
const screen = new ScreenWidget()
381+
const grid = new GridLayout({ rows: 5, cols: 4, screen })
377382

378383
renderLineCharts(
379384
grid,
@@ -432,7 +437,7 @@ const displayAnalyticsScreen = (data: any) => {
432437
data['total_low_prevented']
433438
)
434439

435-
const bar = grid.set(4, 0, 1, 2, contrib.bar, {
440+
const bar = grid.set(4, 0, 1, 2, BarChart, {
436441
label: 'Top 5 alert types',
437442
barWidth: 10,
438443
barSpacing: 17,
@@ -460,7 +465,7 @@ const renderLineCharts = (
460465
coords: number[],
461466
data: { [key: string]: number }
462467
) => {
463-
const line = grid.set(...coords, contrib.line, {
468+
const line = grid.set(...coords, LineChart, {
464469
style: { line: 'cyan', text: 'cyan', baseline: 'black' },
465470
xLabelPadding: 0,
466471
xPadding: 0,

src/commands/threat-feed.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import blessed from 'blessed'
21
// @ts-ignore
3-
import contrib from 'blessed-contrib'
2+
import ScreenWidget from 'blessed/lib/widgets/screen'
3+
// @ts-ignore
4+
import TableWidget from 'blessed-contrib/lib/widget/table'
45
import meow from 'meow'
56
import ora from 'ora'
67

@@ -16,7 +17,7 @@ import type { Ora } from 'ora'
1617
export const threatFeed: CliSubcommand = {
1718
description: 'Look up the threat feed',
1819
async run(argv, importMeta, { parentName }) {
19-
const name = parentName + ' threat-feed'
20+
const name = `${parentName} threat-feed`
2021

2122
const input = setupCommand(name, threatFeed.description, argv, importMeta)
2223
if (input) {
@@ -26,7 +27,7 @@ export const threatFeed: CliSubcommand = {
2627
'User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.'
2728
)
2829
}
29-
const spinner = ora(`Looking up the threat feed \n`).start()
30+
const spinner = ora('Looking up the threat feed').start()
3031
await fetchThreatFeed(input, spinner, apiKey)
3132
}
3233
}
@@ -155,9 +156,9 @@ async function fetchThreatFeed(
155156
return console.log(data)
156157
}
157158

158-
const screen = blessed.screen()
159+
const screen = new ScreenWidget()
159160

160-
const table = contrib.table({
161+
const table = new TableWidget({
161162
keys: 'true',
162163
fg: 'white',
163164
selectedFg: 'white',

0 commit comments

Comments
 (0)