Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps/remove ansistyles ansicolors #4728

Merged
merged 2 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/commands/help-search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs')
const path = require('path')
const color = require('ansicolors')
const chalk = require('chalk')
const { promisify } = require('util')
const glob = promisify(require('glob'))
const readFile = promisify(fs.readFile)
Expand Down Expand Up @@ -173,7 +173,7 @@ class HelpSearch extends BaseCommand {
for (const f of finder) {
hilitLine.push(line.slice(p, p + f.length))
const word = line.slice(p + f.length, p + f.length + arg.length)
const hilit = color.bgBlack(color.red(word))
const hilit = chalk.bgBlack.red(word)
hilitLine.push(hilit)
p += f.length + arg.length
}
Expand Down
13 changes: 6 additions & 7 deletions lib/commands/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ const os = require('os')
const path = require('path')
const pacote = require('pacote')
const table = require('text-table')
const color = require('chalk')
const styles = require('ansistyles')
const chalk = require('chalk')
const npa = require('npm-package-arg')
const pickManifest = require('npm-pick-manifest')
const localeCompare = require('@isaacs/string-locale-compare')('en')
Expand Down Expand Up @@ -106,7 +105,7 @@ class Outdated extends ArboristWorkspaceCmd {
const outTable = [outHead].concat(outList)

if (this.npm.color) {
outTable[0] = outTable[0].map(heading => styles.underline(heading))
outTable[0] = outTable[0].map(heading => chalk.underline(heading))
}

const tableOpts = {
Expand Down Expand Up @@ -282,7 +281,7 @@ class Outdated extends ArboristWorkspaceCmd {
: node.name

return this.npm.color && humanOutput
? color.green(workspaceName)
? chalk.green(workspaceName)
: workspaceName
}

Expand All @@ -307,9 +306,9 @@ class Outdated extends ArboristWorkspaceCmd {
}

if (this.npm.color) {
columns[0] = color[current === wanted ? 'yellow' : 'red'](columns[0]) // current
columns[2] = color.green(columns[2]) // wanted
columns[3] = color.magenta(columns[3]) // latest
columns[0] = chalk[current === wanted ? 'yellow' : 'red'](columns[0]) // current
columns[2] = chalk.green(columns[2]) // wanted
columns[3] = chalk.magenta(columns[3]) // latest
}

return columns
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/profile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const inspect = require('util').inspect
const { URL } = require('url')
const ansistyles = require('ansistyles')
const chalk = require('chalk')
const log = require('../utils/log-shim.js')
const npmProfile = require('npm-profile')
const qrcodeTerminal = require('qrcode-terminal')
Expand Down Expand Up @@ -163,7 +163,7 @@ class Profile extends BaseCommand {
} else {
const table = new Table()
for (const key of Object.keys(cleaned)) {
table.push({ [ansistyles.bright(key)]: cleaned[key] })
table.push({ [chalk.bold(key)]: cleaned[key] })
}

this.npm.output(table.toString())
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/token.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Table = require('cli-table3')
const ansistyles = require('ansistyles')
const chalk = require('chalk')
const { v4: isCidrV4, v6: isCidrV6 } = require('is-cidr')
const log = require('../utils/log-shim.js')
const profile = require('npm-profile')
Expand Down Expand Up @@ -161,7 +161,7 @@ class Token extends BaseCommand {
} else {
const table = new Table()
for (const k of Object.keys(result)) {
table.push({ [ansistyles.bright(k)]: String(result[k]) })
table.push({ [chalk.bold(k)]: String(result[k]) })
}
this.npm.output(table.toString())
}
Expand Down
53 changes: 26 additions & 27 deletions lib/commands/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// npm view [pkg [pkg ...]]

const color = require('ansicolors')
const chalk = require('chalk')
const columns = require('cli-columns')
const fs = require('fs')
const jsonParse = require('json-parse-even-better-errors')
Expand All @@ -13,7 +13,6 @@ const { resolve } = require('path')
const formatBytes = require('../utils/format-bytes.js')
const relativeDate = require('tiny-relative-date')
const semver = require('semver')
const style = require('ansistyles')
const { inspect, promisify } = require('util')
const { packument } = require('pacote')

Expand Down Expand Up @@ -318,34 +317,34 @@ class View extends BaseCommand {

Object.keys(packument['dist-tags']).forEach((t) => {
const version = packument['dist-tags'][t]
tags.push(`${style.bright(color.green(t))}: ${version}`)
tags.push(`${chalk.bold.green(t)}: ${version}`)
})
const unpackedSize = manifest.dist.unpackedSize &&
formatBytes(manifest.dist.unpackedSize, true)
const licenseField = manifest.license || 'Proprietary'
const info = {
name: color.green(manifest.name),
version: color.green(manifest.version),
bins: Object.keys(manifest.bin || {}).map(color.yellow),
versions: color.yellow(packument.versions.length + ''),
name: chalk.green(manifest.name),
version: chalk.green(manifest.version),
bins: Object.keys(manifest.bin || {}),
versions: chalk.yellow(packument.versions.length + ''),
description: manifest.description,
deprecated: manifest.deprecated,
keywords: (packument.keywords || []).map(color.yellow),
keywords: packument.keywords || [],
license: typeof licenseField === 'string'
? licenseField
: (licenseField.type || 'Proprietary'),
deps: Object.keys(manifest.dependencies || {}).map((dep) => {
return `${color.yellow(dep)}: ${manifest.dependencies[dep]}`
return `${chalk.yellow(dep)}: ${manifest.dependencies[dep]}`
}),
publisher: manifest._npmUser && unparsePerson({
name: color.yellow(manifest._npmUser.name),
email: color.cyan(manifest._npmUser.email),
name: chalk.yellow(manifest._npmUser.name),
email: chalk.cyan(manifest._npmUser.email),
}),
modified: !packument.time ? undefined
: color.yellow(relativeDate(packument.time[manifest.version])),
: chalk.yellow(relativeDate(packument.time[manifest.version])),
maintainers: (packument.maintainers || []).map((u) => unparsePerson({
name: color.yellow(u.name),
email: color.cyan(u.email),
name: chalk.yellow(u.name),
email: chalk.cyan(u.email),
})),
repo: (
manifest.bugs && (manifest.bugs.url || manifest.bugs)
Expand All @@ -356,47 +355,47 @@ class View extends BaseCommand {
manifest.homepage && (manifest.homepage.url || manifest.homepage)
),
tags,
tarball: color.cyan(manifest.dist.tarball),
shasum: color.yellow(manifest.dist.shasum),
tarball: chalk.cyan(manifest.dist.tarball),
shasum: chalk.yellow(manifest.dist.shasum),
integrity:
manifest.dist.integrity && color.yellow(manifest.dist.integrity),
manifest.dist.integrity && chalk.yellow(manifest.dist.integrity),
fileCount:
manifest.dist.fileCount && color.yellow(manifest.dist.fileCount),
unpackedSize: unpackedSize && color.yellow(unpackedSize),
manifest.dist.fileCount && chalk.yellow(manifest.dist.fileCount),
unpackedSize: unpackedSize && chalk.yellow(unpackedSize),
}
if (info.license.toLowerCase().trim() === 'proprietary') {
info.license = style.bright(color.red(info.license))
info.license = chalk.bold.red(info.license)
} else {
info.license = color.green(info.license)
info.license = chalk.green(info.license)
}

console.log('')
console.log(
style.underline(style.bright(`${info.name}@${info.version}`)) +
chalk.underline.bold(`${info.name}@${info.version}`) +
' | ' + info.license +
' | deps: ' + (info.deps.length ? color.cyan(info.deps.length) : color.green('none')) +
' | deps: ' + (info.deps.length ? chalk.cyan(info.deps.length) : chalk.green('none')) +
' | versions: ' + info.versions
)
info.description && console.log(info.description)
if (info.repo || info.site) {
info.site && console.log(color.cyan(info.site))
info.site && console.log(chalk.cyan(info.site))
}

const warningSign = unicode ? ' ⚠️ ' : '!!'
info.deprecated && console.log(
`\n${style.bright(color.red('DEPRECATED'))}${
`\n${chalk.bold.red('DEPRECATED')}${
warningSign
} - ${info.deprecated}`
)

if (info.keywords.length) {
console.log('')
console.log('keywords:', info.keywords.join(', '))
console.log('keywords:', chalk.yellow(info.keywords.join(', ')))
}

if (info.bins.length) {
console.log('')
console.log('bin:', info.bins.join(', '))
console.log('bin:', chalk.yellow(info.bins.join(', ')))
}

console.log('')
Expand Down
23 changes: 0 additions & 23 deletions node_modules/ansicolors/LICENSE

This file was deleted.

65 changes: 0 additions & 65 deletions node_modules/ansicolors/ansicolors.js

This file was deleted.

23 changes: 0 additions & 23 deletions node_modules/ansicolors/package.json

This file was deleted.

Loading