Skip to content

Commit a6f87a0

Browse files
committed
Replace chalk with yoctocolors
1 parent 0b6f176 commit a6f87a0

26 files changed

+161
-200
lines changed

.dep-stats.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
"tinyglobby": "^0.2.10",
2424
"which": "^5.0.0",
2525
"yaml": "^2.6.0",
26-
"yargs-parser": "^21.1.1"
26+
"yargs-parser": "^21.1.1",
27+
"yoctocolors-cjs": "^2.1.2"
2728
},
2829
"devDependencies": {},
2930
"esm": {
3031
"ansi-escapes": "^5.0.0",
3132
"bundle-name": "^4.1.0",
32-
"chalk": "^5.3.0",
3333
"default-browser": "^5.2.1",
3434
"default-browser-id": "^5.0.0",
3535
"define-lazy-prop": "^3.0.0",
@@ -75,7 +75,8 @@
7575
"tinyglobby": "^0.2.10",
7676
"which": "^5.0.0",
7777
"yaml": "^2.6.0",
78-
"yargs-parser": "^21.1.1"
78+
"yargs-parser": "^21.1.1",
79+
"yoctocolors-cjs": "^2.1.2"
7980
},
8081
"transitives": {
8182
"cli-spinners": "^3.2.0",

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
"tinyglobby": "^0.2.10",
6767
"which": "^5.0.0",
6868
"yaml": "^2.6.0",
69-
"yargs-parser": "^21.1.1"
69+
"yargs-parser": "^21.1.1",
70+
"yoctocolors-cjs": "^2.1.2"
7071
},
7172
"devDependencies": {
7273
"@babel/core": "^7.26.0",
@@ -100,7 +101,6 @@
100101
"@typescript-eslint/eslint-plugin": "^8.14.0",
101102
"@typescript-eslint/parser": "^8.14.0",
102103
"c8": "^10.1.2",
103-
"chalk": "^5.3.0",
104104
"eslint": "^9.14.0",
105105
"eslint-import-resolver-oxc": "^0.4.0",
106106
"eslint-plugin-depend": "^0.12.0",

src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import path from 'node:path'
44
import { pathToFileURL } from 'node:url'
55

6-
import chalk from 'chalk'
6+
import colors from 'yoctocolors-cjs'
77
import { messageWithCauses, stackWithCauses } from 'pony-cause'
88
import updateNotifier from 'tiny-updater'
99

@@ -69,7 +69,7 @@ void (async () => {
6969
errorTitle = 'Unexpected error with no details'
7070
}
7171
console.error(
72-
`${logSymbols.error} ${chalk.white.bgRed(errorTitle + ':')} ${errorMessage}`
72+
`${logSymbols.error} ${colors.bgRed(colors.white(errorTitle + ':'))} ${errorMessage}`
7373
)
7474
if (errorBody) {
7575
console.error(`\n${errorBody}`)

src/commands/analytics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import BarChart from 'blessed-contrib/lib/widget/charts/bar'
88
import GridLayout from 'blessed-contrib/lib/layout/grid'
99
// @ts-ignore
1010
import LineChart from 'blessed-contrib/lib/widget/charts/line'
11-
import chalk from 'chalk'
1211
import meow from 'meow'
12+
import colors from 'yoctocolors-cjs'
1313
import yoctoSpinner from '@socketregistry/yocto-spinner'
1414

1515
import { commonFlags, outputFlags } from '../flags'
@@ -142,7 +142,7 @@ function setupCommand(
142142
if (scope === 'repo' && !repo) {
143143
showHelp = true
144144
console.error(
145-
`${chalk.bgRed.white('Input error')}: Please provide a repository name when using the repository scope.`
145+
`${colors.bgRed(colors.white('Input error'))}: Please provide a repository name when using the repository scope.`
146146
)
147147
}
148148
if (showHelp) {

src/commands/audit-log.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Separator, select } from '@inquirer/prompts'
2-
import chalk from 'chalk'
2+
import colors from 'yoctocolors-cjs'
33
import meow from 'meow'
44
import yoctoSpinner from '@socketregistry/yocto-spinner'
55

@@ -101,7 +101,7 @@ function setupCommand(
101101
if (cli.input.length < 1) {
102102
showHelp = true
103103
console.error(
104-
`${chalk.white.bgRed('Input error')}: Please provide an organization slug.`
104+
`${colors.bgRed(colors.white('Input error'))}: Please provide an organization slug.`
105105
)
106106
}
107107
if (showHelp) {

src/commands/cdxgen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { existsSync, promises as fs } from 'node:fs'
22
import path from 'node:path'
33

44
import spawn from '@npmcli/promise-spawn'
5-
import chalk from 'chalk'
5+
import colors from 'yoctocolors-cjs'
66
import yargsParse from 'yargs-parser'
77

88
import type { CliSubcommand } from '../utils/meow-with-subcommands'
@@ -210,7 +210,7 @@ export const cdxgen: CliSubcommand = {
210210
}
211211
const fullOutputPath = path.join(process.cwd(), yargv.output)
212212
if (existsSync(fullOutputPath)) {
213-
console.log(chalk.cyanBright(`${yargv.output} created!`))
213+
console.log(colors.cyanBright(`${yargv.output} created!`))
214214
}
215215
}
216216
}

src/commands/dependencies.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from 'chalk'
1+
import colors from 'yoctocolors-cjs'
22
// @ts-ignore
33
import chalkTable from 'chalk-table'
44
import meow from 'meow'
@@ -135,13 +135,13 @@ async function searchDeps({
135135

136136
const options = {
137137
columns: [
138-
{ field: 'namespace', name: chalk.cyan('Namespace') },
139-
{ field: 'name', name: chalk.cyan('Name') },
140-
{ field: 'version', name: chalk.cyan('Version') },
141-
{ field: 'repository', name: chalk.cyan('Repository') },
142-
{ field: 'branch', name: chalk.cyan('Branch') },
143-
{ field: 'type', name: chalk.cyan('Type') },
144-
{ field: 'direct', name: chalk.cyan('Direct') }
138+
{ field: 'namespace', name: colors.cyan('Namespace') },
139+
{ field: 'name', name: colors.cyan('Name') },
140+
{ field: 'version', name: colors.cyan('Version') },
141+
{ field: 'repository', name: colors.cyan('Repository') },
142+
{ field: 'branch', name: colors.cyan('Branch') },
143+
{ field: 'type', name: colors.cyan('Type') },
144+
{ field: 'direct', name: colors.cyan('Direct') }
145145
]
146146
}
147147

src/commands/diff-scan/get.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs'
22
import util from 'node:util'
33

4-
import chalk from 'chalk'
4+
import colors from 'yoctocolors-cjs'
55
import meow from 'meow'
66
import yoctoSpinner from '@socketregistry/yocto-spinner'
77

@@ -106,12 +106,12 @@ function setupCommand(
106106
if (!before || !after) {
107107
showHelp = true
108108
console.error(
109-
`${chalk.bgRed.white('Input error')}: Please specify a before and after full scan ID. To get full scans IDs, you can run the command "socket scan list <your org slug>".\n`
109+
`${colors.bgRed(colors.white('Input error'))}: Please specify a before and after full scan ID. To get full scans IDs, you can run the command "socket scan list <your org slug>".`
110110
)
111111
} else if (cli.input.length < 1) {
112112
showHelp = true
113113
console.error(
114-
`${chalk.bgRed.white('Input error')}: Please provide an organization slug\n`
114+
`${colors.bgRed(colors.white('Input error'))}: Please provide an organization slug.`
115115
)
116116
}
117117
if (showHelp) {
@@ -144,7 +144,7 @@ async function getDiffScan(
144144
if (!response.ok) {
145145
spinner.stop()
146146
const err = await handleAPIError(response.status)
147-
console.error(`${chalk.bgRed.white(response.statusText)}: ${err}`)
147+
console.error(`${colors.bgRed(colors.white(response.statusText))}: ${err}`)
148148
return
149149
}
150150

@@ -164,20 +164,18 @@ async function getDiffScan(
164164
console.log(
165165
util.inspect(data, { showHidden: false, depth: null, colors: true })
166166
)
167-
// @ts-ignore
168167
console.log(
169-
`\n View this diff scan in the Socket dashboard: ${chalk.cyan((data as any)?.['diff_report_url'])}\n`
168+
`\n View this diff scan in the Socket dashboard: ${colors.cyan((data as any)?.['diff_report_url'])}`
170169
)
171170
return
172171
}
173172

174-
console.log('Diff scan result: ')
173+
console.log('Diff scan result:')
175174
console.log(data)
176175
console.log(
177176
`\n 📝 To display the detailed report in the terminal, use the --json flag \n`
178177
)
179-
// @ts-ignore
180178
console.log(
181-
`\n View this diff scan in the Socket dashboard: ${chalk.cyan((data as any)?.['diff_report_url'])}\n`
179+
`\n View this diff scan in the Socket dashboard: ${colors.cyan((data as any)?.['diff_report_url'])}`
182180
)
183181
}

src/commands/info.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from 'chalk'
1+
import colors from 'yoctocolors-cjs'
22
import meow from 'meow'
33
import yoctoSpinner from '@socketregistry/yocto-spinner'
44

@@ -227,12 +227,8 @@ function formatPackageDataOutput(
227227
}
228228
if (!outputMarkdown) {
229229
console.log(
230-
chalk.dim(
231-
'\nOr rerun',
232-
chalk.italic(name),
233-
'using the',
234-
chalk.italic('--json'),
235-
'flag to get full JSON output'
230+
colors.dim(
231+
`\nOr rerun ${colors.italic(name)} using the ${colors.italic('--json')} flag to get full JSON output`
236232
)
237233
)
238234
}
@@ -288,14 +284,10 @@ function formatPackageIssuesDetails(
288284
}
289285

290286
function formatScore(score: number): string {
291-
const error = chalk.hex('#de7c7b')
292-
const warning = chalk.hex('#e59361')
293-
const success = chalk.hex('#a4cb9d')
294-
295287
if (score > 80) {
296-
return `${success(score)}`
288+
return colors.green(`${score}`)
297289
} else if (score < 80 && score > 60) {
298-
return `${warning(score)}`
290+
return colors.yellow(`${score}`)
299291
}
300-
return `${error(score)}`
292+
return colors.red(`${score}`)
301293
}

0 commit comments

Comments
 (0)