diff --git a/lib/commands/outdated.js b/lib/commands/outdated.js index 0cb5b4247a000..1420d94cd5319 100644 --- a/lib/commands/outdated.js +++ b/lib/commands/outdated.js @@ -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') @@ -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 = { @@ -282,7 +281,7 @@ class Outdated extends ArboristWorkspaceCmd { : node.name return this.npm.color && humanOutput - ? color.green(workspaceName) + ? chalk.green(workspaceName) : workspaceName } @@ -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 diff --git a/lib/commands/profile.js b/lib/commands/profile.js index a82d31fd443a9..fcf0eb7d53fa6 100644 --- a/lib/commands/profile.js +++ b/lib/commands/profile.js @@ -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') @@ -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()) diff --git a/lib/commands/token.js b/lib/commands/token.js index f57c212c49e45..edfb07b9d3a9a 100644 --- a/lib/commands/token.js +++ b/lib/commands/token.js @@ -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') @@ -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()) } diff --git a/lib/commands/view.js b/lib/commands/view.js index 99cf2981306fa..afe4b24282bd9 100644 --- a/lib/commands/view.js +++ b/lib/commands/view.js @@ -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') @@ -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') @@ -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) @@ -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 @@ -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}` ) diff --git a/node_modules/ansistyles/LICENSE b/node_modules/ansistyles/LICENSE deleted file mode 100644 index 41702c5043478..0000000000000 --- a/node_modules/ansistyles/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2013 Thorsten Lorenz. -All rights reserved. - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/ansistyles/ansistyles.js b/node_modules/ansistyles/ansistyles.js deleted file mode 100644 index 5b8788c0f9419..0000000000000 --- a/node_modules/ansistyles/ansistyles.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -/* - * Info: http://www.termsys.demon.co.uk/vtansi.htm#colors - * Following caveats - * bright - brightens the color (bold-blue is same as brigthtBlue) - * dim - nothing on Mac or Linux - * italic - nothing on Mac or Linux - * underline - underlines string - * blink - nothing on Mac or linux - * inverse - background becomes foreground and vice versa - * - * In summary, the only styles that work are: - * - bright, underline and inverse - * - the others are only included for completeness - */ - -var styleNums = { - reset : [0, 22] - , bright : [1, 22] - , dim : [2, 22] - , italic : [3, 23] - , underline : [4, 24] - , blink : [5, 25] - , inverse : [7, 27] - } - , styles = {} - ; - -Object.keys(styleNums).forEach(function (k) { - styles[k] = function (s) { - var open = styleNums[k][0] - , close = styleNums[k][1]; - return '\u001b[' + open + 'm' + s + '\u001b[' + close + 'm'; - }; -}); - -module.exports = styles; diff --git a/node_modules/ansistyles/package.json b/node_modules/ansistyles/package.json deleted file mode 100644 index 2fe1f4da4fffa..0000000000000 --- a/node_modules/ansistyles/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "ansistyles", - "version": "0.1.3", - "description": "Functions that surround a string with ansistyle codes so it prints in style.", - "main": "ansistyles.js", - "scripts": { - "test": "node test/ansistyles.js" - }, - "repository": { - "type": "git", - "url": "git://github.com/thlorenz/ansistyles.git" - }, - "keywords": [ - "ansi", - "style", - "terminal", - "console" - ], - "author": "Thorsten Lorenz (thlorenz.com)", - "license": "MIT", - "readmeFilename": "README.md", - "gitHead": "27bf1bc65231bcc7fd109bf13b13601b51f8cd04" -} diff --git a/node_modules/ansistyles/test/ansistyles.js b/node_modules/ansistyles/test/ansistyles.js deleted file mode 100644 index f769bf803b209..0000000000000 --- a/node_modules/ansistyles/test/ansistyles.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; -/*jshint asi: true */ -var assert = require('assert') - , styles = require('../') - -function inspect(obj, depth) { - console.log(require('util').inspect(obj, false, depth || 5, true)); -} - -assert.equal(styles.reset('reset'), '\u001b[0mreset\u001b[22m', 'reset') -assert.equal(styles.underline('underlined'), '\u001b[4munderlined\u001b[24m', 'underline') -assert.equal(styles.bright('bright'), '\u001b[1mbright\u001b[22m', 'bright') -assert.equal(styles.inverse('inversed'), '\u001b[7minversed\u001b[27m', 'inverse') - -console.log('OK'); diff --git a/package-lock.json b/package-lock.json index f53bbee66173e..3704afac626c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,6 @@ "@npmcli/run-script", "abbrev", "ansicolors", - "ansistyles", "archy", "cacache", "chalk", @@ -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", @@ -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, @@ -10782,9 +10775,6 @@ "ansicolors": { "version": "0.3.2" }, - "ansistyles": { - "version": "0.1.3" - }, "anymatch": { "version": "3.1.2", "dev": true, diff --git a/package.json b/package.json index f4fbaed09ba18..548e509ded1f2 100644 --- a/package.json +++ b/package.json @@ -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", @@ -139,7 +138,6 @@ "@npmcli/run-script", "abbrev", "ansicolors", - "ansistyles", "archy", "cacache", "chalk", diff --git a/tap-snapshots/test/lib/commands/profile.js.test.cjs b/tap-snapshots/test/lib/commands/profile.js.test.cjs index 31205b7fedc05..2103ccdd32e33 100644 --- a/tap-snapshots/test/lib/commands/profile.js.test.cjs +++ b/tap-snapshots/test/lib/commands/profile.js.test.cjs @@ -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 +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 ` 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 +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 ` 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 +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 ` 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 +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 ` exports[`test/lib/commands/profile.js TAP profile set writable key --parseable > should output parseable set key success msg 1`] = ` diff --git a/test/lib/commands/profile.js b/test/lib/commands/profile.js index da32d4300840a..09fd08cfc5329 100644 --- a/test/lib/commands/profile.js +++ b/test/lib/commands/profile.js @@ -19,7 +19,6 @@ const npm = mockNpm({ }, }) const mocks = { - ansistyles: { bright: a => a }, npmlog: { gauge: { show () {} }, },