Skip to content

Commit

Permalink
deps: remove ansistyles
Browse files Browse the repository at this point in the history
chalk is already in use elsewhere and does what we need
  • Loading branch information
wraithgar authored and fritzy committed Apr 13, 2022
1 parent 0cd852f commit 605ccef
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 169 deletions.
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
10 changes: 5 additions & 5 deletions lib/commands/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,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 +14,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,7 +318,7 @@ 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(color.green(t))}: ${version}`)
})
const unpackedSize = manifest.dist.unpackedSize &&
formatBytes(manifest.dist.unpackedSize, true)
Expand Down Expand Up @@ -365,14 +365,14 @@ class View extends BaseCommand {
unpackedSize: unpackedSize && color.yellow(unpackedSize),
}
if (info.license.toLowerCase().trim() === 'proprietary') {
info.license = style.bright(color.red(info.license))
info.license = chalk.bold(color.red(info.license))
} else {
info.license = color.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')) +
' | versions: ' + info.versions
Expand All @@ -384,7 +384,7 @@ class View extends BaseCommand {

const warningSign = unicode ? ' ⚠️ ' : '!!'
info.deprecated && console.log(
`\n${style.bright(color.red('DEPRECATED'))}${
`\n${chalk.bold(color.red('DEPRECATED'))}${
warningSign
} - ${info.deprecated}`
)
Expand Down
23 changes: 0 additions & 23 deletions node_modules/ansistyles/LICENSE

This file was deleted.

38 changes: 0 additions & 38 deletions node_modules/ansistyles/ansistyles.js

This file was deleted.

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

This file was deleted.

15 changes: 0 additions & 15 deletions node_modules/ansistyles/test/ansistyles.js

This file was deleted.

10 changes: 0 additions & 10 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"@npmcli/run-script",
"abbrev",
"ansicolors",
"ansistyles",
"archy",
"cacache",
"chalk",
Expand Down Expand Up @@ -98,7 +97,6 @@
"@npmcli/run-script": "^3.0.1",
"abbrev": "~1.1.1",
"ansicolors": "~0.3.2",
"ansistyles": "~0.1.3",
"archy": "~1.0.0",
"cacache": "^16.0.4",
"chalk": "^4.1.2",
Expand Down Expand Up @@ -1248,11 +1246,6 @@
"inBundle": true,
"license": "MIT"
},
"node_modules/ansistyles": {
"version": "0.1.3",
"inBundle": true,
"license": "MIT"
},
"node_modules/anymatch": {
"version": "3.1.2",
"dev": true,
Expand Down Expand Up @@ -10782,9 +10775,6 @@
"ansicolors": {
"version": "0.3.2"
},
"ansistyles": {
"version": "0.1.3"
},
"anymatch": {
"version": "3.1.2",
"dev": true,
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"@npmcli/run-script": "^3.0.1",
"abbrev": "~1.1.1",
"ansicolors": "~0.3.2",
"ansistyles": "~0.1.3",
"archy": "~1.0.0",
"cacache": "^16.0.4",
"chalk": "^4.1.2",
Expand Down Expand Up @@ -139,7 +138,6 @@
"@npmcli/run-script",
"abbrev",
"ansicolors",
"ansistyles",
"archy",
"cacache",
"chalk",
Expand Down
82 changes: 41 additions & 41 deletions tap-snapshots/test/lib/commands/profile.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,56 +47,56 @@ github https://github.com/npm
`

exports[`test/lib/commands/profile.js TAP profile get no args default output > should output table with contents 1`] = `
name: foo
email: foo@github.com (verified)
two-factor auth: auth-and-writes
fullname: Foo Bar
homepage: https://github.com
freenode: foobar
twitter: https://twitter.com/npmjs
github: https://github.com/npm
created: 2015-02-26T01:26:37.384Z
updated: 2020-08-12T16:19:35.326Z
[1mname[22m: foo
[1memail[22m: foo@github.com (verified)
[1mtwo-factor auth[22m: auth-and-writes
[1mfullname[22m: Foo Bar
[1mhomepage[22m: https://github.com
[1mfreenode[22m: foobar
[1mtwitter[22m: https://twitter.com/npmjs
[1mgithub[22m: https://github.com/npm
[1mcreated[22m: 2015-02-26T01:26:37.384Z
[1mupdated[22m: 2020-08-12T16:19:35.326Z
`

exports[`test/lib/commands/profile.js TAP profile get no args no tfa enabled > should output expected profile values 1`] = `
name: foo
email: foo@github.com (verified)
two-factor auth: disabled
fullname: Foo Bar
homepage: https://github.com
freenode: foobar
twitter: https://twitter.com/npmjs
github: https://github.com/npm
created: 2015-02-26T01:26:37.384Z
updated: 2020-08-12T16:19:35.326Z
[1mname[22m: foo
[1memail[22m: foo@github.com (verified)
[1mtwo-factor auth[22m: disabled
[1mfullname[22m: Foo Bar
[1mhomepage[22m: https://github.com
[1mfreenode[22m: foobar
[1mtwitter[22m: https://twitter.com/npmjs
[1mgithub[22m: https://github.com/npm
[1mcreated[22m: 2015-02-26T01:26:37.384Z
[1mupdated[22m: 2020-08-12T16:19:35.326Z
`

exports[`test/lib/commands/profile.js TAP profile get no args profile has cidr_whitelist item > should output table with contents 1`] = `
name: foo
email: foo@github.com (verified)
two-factor auth: auth-and-writes
fullname: Foo Bar
homepage: https://github.com
freenode: foobar
twitter: https://twitter.com/npmjs
github: https://github.com/npm
created: 2015-02-26T01:26:37.384Z
updated: 2020-08-12T16:19:35.326Z
cidr_whitelist: 192.168.1.1
[1mname[22m: foo
[1memail[22m: foo@github.com (verified)
[1mtwo-factor auth[22m: auth-and-writes
[1mfullname[22m: Foo Bar
[1mhomepage[22m: https://github.com
[1mfreenode[22m: foobar
[1mtwitter[22m: https://twitter.com/npmjs
[1mgithub[22m: https://github.com/npm
[1mcreated[22m: 2015-02-26T01:26:37.384Z
[1mupdated[22m: 2020-08-12T16:19:35.326Z
[1mcidr_whitelist[22m: 192.168.1.1
`

exports[`test/lib/commands/profile.js TAP profile get no args unverified email > should output table with contents 1`] = `
name: foo
email: foo@github.com(unverified)
two-factor auth: auth-and-writes
fullname: Foo Bar
homepage: https://github.com
freenode: foobar
twitter: https://twitter.com/npmjs
github: https://github.com/npm
created: 2015-02-26T01:26:37.384Z
updated: 2020-08-12T16:19:35.326Z
[1mname[22m: foo
[1memail[22m: foo@github.com(unverified)
[1mtwo-factor auth[22m: auth-and-writes
[1mfullname[22m: Foo Bar
[1mhomepage[22m: https://github.com
[1mfreenode[22m: foobar
[1mtwitter[22m: https://twitter.com/npmjs
[1mgithub[22m: https://github.com/npm
[1mcreated[22m: 2015-02-26T01:26:37.384Z
[1mupdated[22m: 2020-08-12T16:19:35.326Z
`

exports[`test/lib/commands/profile.js TAP profile set <key> <value> writable key --parseable > should output parseable set key success msg 1`] = `
Expand Down
1 change: 0 additions & 1 deletion test/lib/commands/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const npm = mockNpm({
},
})
const mocks = {
ansistyles: { bright: a => a },
npmlog: {
gauge: { show () {} },
},
Expand Down

0 comments on commit 605ccef

Please sign in to comment.