diff --git a/lib/commands/help-search.js b/lib/commands/help-search.js index 3387ac8eb542c..23b426eaa016d 100644 --- a/lib/commands/help-search.js +++ b/lib/commands/help-search.js @@ -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) @@ -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 } diff --git a/lib/commands/view.js b/lib/commands/view.js index afe4b24282bd9..403d09d813dc7 100644 --- a/lib/commands/view.js +++ b/lib/commands/view.js @@ -3,7 +3,6 @@ // npm view [pkg [pkg ...]] -const color = require('ansicolors') const chalk = require('chalk') const columns = require('cli-columns') const fs = require('fs') @@ -318,34 +317,34 @@ class View extends BaseCommand { Object.keys(packument['dist-tags']).forEach((t) => { const version = packument['dist-tags'][t] - tags.push(`${chalk.bold(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) @@ -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 = chalk.bold(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( 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${chalk.bold(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('') diff --git a/node_modules/ansicolors/LICENSE b/node_modules/ansicolors/LICENSE deleted file mode 100644 index 41702c5043478..0000000000000 --- a/node_modules/ansicolors/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/ansicolors/ansicolors.js b/node_modules/ansicolors/ansicolors.js deleted file mode 100644 index 16b2586f6b163..0000000000000 --- a/node_modules/ansicolors/ansicolors.js +++ /dev/null @@ -1,65 +0,0 @@ -// ColorCodes explained: http://www.termsys.demon.co.uk/vtansi.htm -'use strict'; - -var colorNums = { - white : 37 - , black : 30 - , blue : 34 - , cyan : 36 - , green : 32 - , magenta : 35 - , red : 31 - , yellow : 33 - , brightBlack : 90 - , brightRed : 91 - , brightGreen : 92 - , brightYellow : 93 - , brightBlue : 94 - , brightMagenta : 95 - , brightCyan : 96 - , brightWhite : 97 - } - , backgroundColorNums = { - bgBlack : 40 - , bgRed : 41 - , bgGreen : 42 - , bgYellow : 43 - , bgBlue : 44 - , bgMagenta : 45 - , bgCyan : 46 - , bgWhite : 47 - , bgBrightBlack : 100 - , bgBrightRed : 101 - , bgBrightGreen : 102 - , bgBrightYellow : 103 - , bgBrightBlue : 104 - , bgBrightMagenta : 105 - , bgBrightCyan : 106 - , bgBrightWhite : 107 - } - , open = {} - , close = {} - , colors = {} - ; - -Object.keys(colorNums).forEach(function (k) { - var o = open[k] = '\u001b[' + colorNums[k] + 'm'; - var c = close[k] = '\u001b[39m'; - - colors[k] = function (s) { - return o + s + c; - }; -}); - -Object.keys(backgroundColorNums).forEach(function (k) { - var o = open[k] = '\u001b[' + backgroundColorNums[k] + 'm'; - var c = close[k] = '\u001b[49m'; - - colors[k] = function (s) { - return o + s + c; - }; -}); - -module.exports = colors; -colors.open = open; -colors.close = close; diff --git a/node_modules/ansicolors/package.json b/node_modules/ansicolors/package.json deleted file mode 100644 index cda0c75b5850a..0000000000000 --- a/node_modules/ansicolors/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "ansicolors", - "version": "0.3.2", - "description": "Functions that surround a string with ansicolor codes so it prints in color.", - "main": "ansicolors.js", - "scripts": { - "test": "node test/*.js" - }, - "repository": { - "type": "git", - "url": "git://github.com/thlorenz/ansicolors.git" - }, - "keywords": [ - "ansi", - "colors", - "highlight", - "string" - ], - "author": "Thorsten Lorenz (thlorenz.com)", - "license": "MIT", - "readmeFilename": "README.md", - "gitHead": "858847ca28e8b360d9b70eee0592700fa2ab087d" -} diff --git a/node_modules/ansicolors/test/ansicolors.js b/node_modules/ansicolors/test/ansicolors.js deleted file mode 100644 index 494539305d3ac..0000000000000 --- a/node_modules/ansicolors/test/ansicolors.js +++ /dev/null @@ -1,71 +0,0 @@ -'use strict'; - -var assert = require('assert') - , colors = require('..') - , open = colors.open - , close = colors.close - -console.log('Foreground colors ..'); - -assert.equal(colors.white('printed in white'), '\u001b[37mprinted in white\u001b[39m'); - -assert.equal(colors.black('printed in black'), '\u001b[30mprinted in black\u001b[39m'); -assert.equal(colors.brightBlack('printed in bright black'), '\u001b[90mprinted in bright black\u001b[39m'); - -assert.equal(colors.green('printed in green'), '\u001b[32mprinted in green\u001b[39m'); -assert.equal(colors.brightGreen('printed in bright green'), '\u001b[92mprinted in bright green\u001b[39m'); - -assert.equal(colors.red('printed in red'), '\u001b[31mprinted in red\u001b[39m'); -assert.equal(colors.brightRed('printed in bright red'), '\u001b[91mprinted in bright red\u001b[39m'); - -console.log('OK'); - -console.log('Background colors ..'); - -assert.equal( - colors.bgBlack('printed with black background') - , '\u001b[40mprinted with black background\u001b[49m' -); - -assert.equal( - colors.bgYellow('printed with yellow background') - , '\u001b[43mprinted with yellow background\u001b[49m' -); -assert.equal( - colors.bgBrightYellow('printed with bright yellow background') - , '\u001b[103mprinted with bright yellow background\u001b[49m' -); - -assert.equal( - colors.bgWhite('printed with white background') - , '\u001b[47mprinted with white background\u001b[49m' -); - -console.log('OK'); - -console.log('Mixing background and foreground colors ..'); - -assert.equal( - colors.blue(colors.bgYellow('printed in blue with yellow background')) - , '\u001b[34m\u001b[43mprinted in blue with yellow background\u001b[49m\u001b[39m' -); -assert.equal( - colors.bgYellow(colors.blue('printed in blue with yellow background again')) - , '\u001b[43m\u001b[34mprinted in blue with yellow background again\u001b[39m\u001b[49m' -); - -console.log('OK'); - -console.log('Open ...'); - -assert.equal(open.black, '\u001b[30m'); -assert.equal(open.bgYellow, '\u001b[43m'); - -console.log('OK'); - -console.log('Close ...'); - -assert.equal(close.black, '\u001b[39m'); -assert.equal(close.bgYellow, '\u001b[49m'); - -console.log('OK'); diff --git a/package-lock.json b/package-lock.json index 3704afac626c5..5138eee431c5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,6 @@ "@npmcli/package-json", "@npmcli/run-script", "abbrev", - "ansicolors", "archy", "cacache", "chalk", @@ -96,7 +95,6 @@ "@npmcli/package-json": "^2.0.0", "@npmcli/run-script": "^3.0.1", "abbrev": "~1.1.1", - "ansicolors": "~0.3.2", "archy": "~1.0.0", "cacache": "^16.0.4", "chalk": "^4.1.2", @@ -1241,11 +1239,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/ansicolors": { - "version": "0.3.2", - "inBundle": true, - "license": "MIT" - }, "node_modules/anymatch": { "version": "3.1.2", "dev": true, @@ -10772,9 +10765,6 @@ "color-convert": "^2.0.1" } }, - "ansicolors": { - "version": "0.3.2" - }, "anymatch": { "version": "3.1.2", "dev": true, diff --git a/package.json b/package.json index 548e509ded1f2..44e5beca0a121 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,6 @@ "@npmcli/package-json": "^2.0.0", "@npmcli/run-script": "^3.0.1", "abbrev": "~1.1.1", - "ansicolors": "~0.3.2", "archy": "~1.0.0", "cacache": "^16.0.4", "chalk": "^4.1.2", @@ -137,7 +136,6 @@ "@npmcli/package-json", "@npmcli/run-script", "abbrev", - "ansicolors", "archy", "cacache", "chalk", diff --git a/smoke-tests/tap-snapshots/test/index.js.test.cjs b/smoke-tests/tap-snapshots/test/index.js.test.cjs index 486849d6cbf54..5a13b4e9a5c20 100644 --- a/smoke-tests/tap-snapshots/test/index.js.test.cjs +++ b/smoke-tests/tap-snapshots/test/index.js.test.cjs @@ -761,24 +761,24 @@ changed 1 package exports[`test/index.js TAP npm view > should have expected view output 1`] = ` -abbrev@1.0.4 | MIT | deps: none | versions: 8 +abbrev@1.0.4 | MIT | deps: none | versions: 8 Like ruby's abbrev module, but in js -https://github.com/isaacs/abbrev-js#readme +https://github.com/isaacs/abbrev-js#readme dist -.tarball: https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz -.shasum: bd55ae5e413ba1722ee4caba1f6ea10414a59ecd +.tarball: https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz +.shasum: bd55ae5e413ba1722ee4caba1f6ea10414a59ecd maintainers: -- nlf <quitlahok@gmail.com> -- ruyadorno <ruyadorno@hotmail.com> -- darcyclarke <darcy@darcyclarke.me> -- adam_baldwin <evilpacket@gmail.com> -- isaacs <i@izs.me> +- nlf +- ruyadorno +- darcyclarke +- adam_baldwin +- isaacs dist-tags: -latest: 1.1.1 +latest: 1.1.1 -published over a year ago by isaacs <i@izs.me> +published over a year ago by isaacs ` diff --git a/tap-snapshots/test/lib/commands/view.js.test.cjs b/tap-snapshots/test/lib/commands/view.js.test.cjs index 229a9d323dbae..5868e7b04babe 100644 --- a/tap-snapshots/test/lib/commands/view.js.test.cjs +++ b/tap-snapshots/test/lib/commands/view.js.test.cjs @@ -127,7 +127,7 @@ green is a very important color DEPRECATED!! - true -keywords:colors, green, crayola +keywords:colors, green, crayola bin:green @@ -209,7 +209,7 @@ green is a very important color DEPRECATED!! - true -keywords:colors, green, crayola +keywords:colors, green, crayola bin:green @@ -440,7 +440,7 @@ green is a very important color DEPRECATED!! - true -keywords:colors, green, crayola +keywords:colors, green, crayola bin:green @@ -508,7 +508,7 @@ green is a very important color DEPRECATED!! - true -keywords:colors, green, crayola +keywords:colors, green, crayola bin:green diff --git a/test/lib/commands/help-search.js b/test/lib/commands/help-search.js index 8d13009a22252..7fbeb195d23c7 100644 --- a/test/lib/commands/help-search.js +++ b/test/lib/commands/help-search.js @@ -1,7 +1,7 @@ const t = require('tap') const { join } = require('path') const { fake: mockNpm } = require('../../fixtures/mock-npm') -const ansicolors = require('ansicolors') +const chalk = require('chalk') const OUTPUT = [] const output = msg => { @@ -106,7 +106,7 @@ t.test('npm help-search long output with color', async t => { await helpSearch.exec(['help-search']) - const highlightedText = ansicolors.bgBlack(ansicolors.red('help-search')) + const highlightedText = chalk.bgBlack.red('help-search') t.equal( OUTPUT.some(line => line.includes(highlightedText)), true,