Skip to content

Commit

Permalink
deps: chalk@5.2.0, npm-audit-report@5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed May 26, 2023
1 parent 9e7f5ac commit 060d587
Show file tree
Hide file tree
Showing 37 changed files with 1,076 additions and 944 deletions.
5 changes: 0 additions & 5 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,6 @@ graph LR;
cacache-->ssri;
cacache-->tar;
cacache-->unique-filename;
chalk-->ansi-styles;
chalk-->supports-color;
cidr-regex-->ip-regex;
cli-columns-->string-width;
cli-columns-->strip-ansi;
Expand Down Expand Up @@ -583,7 +581,6 @@ graph LR;
npm-->validate-npm-package-name;
npm-->which;
npm-->write-file-atomic;
npm-audit-report-->chalk;
npm-bundled-->npm-normalize-package-bin;
npm-install-checks-->semver;
npm-package-arg-->hosted-git-info;
Expand All @@ -607,7 +604,6 @@ graph LR;
npmcli-arborist-->benchmark;
npmcli-arborist-->bin-links;
npmcli-arborist-->cacache;
npmcli-arborist-->chalk;
npmcli-arborist-->common-ancestor-path;
npmcli-arborist-->hosted-git-info;
npmcli-arborist-->isaacs-string-locale-compare["@isaacs/string-locale-compare"];
Expand Down Expand Up @@ -787,7 +783,6 @@ graph LR;
string-width-->strip-ansi;
string_decoder-->safe-buffer;
strip-ansi-->ansi-regex;
supports-color-->has-flag;
tar-->chownr;
tar-->fs-minipass;
tar-->minipass;
Expand Down
7 changes: 5 additions & 2 deletions lib/commands/audit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const auditReport = require('npm-audit-report')
const npmAuditReport = require('npm-audit-report')
const fetch = require('npm-registry-fetch')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const npa = require('npm-package-arg')
Expand Down Expand Up @@ -457,7 +457,10 @@ class Audit extends ArboristWorkspaceCmd {
} else {
// will throw if there's an error, because this is an audit command
auditError(this.npm, arb.auditReport)
const result = auditReport(arb.auditReport, opts)
const result = npmAuditReport(arb.auditReport, {
...opts,
chalk: this.npm.chalk,
})
process.exitCode = process.exitCode || result.exitCode
this.npm.output(result.report)
}
Expand Down
2 changes: 2 additions & 0 deletions lib/commands/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Exec extends BaseCommand {
localBin,
globalBin,
globalDir,
chalk,
} = this.npm
const output = this.npm.output.bind(this.npm)
const scriptShell = this.npm.config.get('script-shell') || undefined
Expand Down Expand Up @@ -83,6 +84,7 @@ class Exec extends BaseCommand {
globalBin,
globalPath,
output,
chalk,
packages,
path: localPrefix,
runPath,
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ class Init extends BaseCommand {
}

const newArgs = [packageName, ...otherArgs]
const { color } = this.npm.flatOptions
const {
flatOptions,
localBin,
globalBin,
chalk,
} = this.npm
const output = this.npm.output.bind(this.npm)
const runPath = path
Expand All @@ -133,10 +133,10 @@ class Init extends BaseCommand {
await libexec({
...flatOptions,
args: newArgs,
color,
localBin,
globalBin,
output,
chalk,
path,
runPath,
scriptShell,
Expand Down
25 changes: 11 additions & 14 deletions lib/npm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { resolve, dirname, join } = require('path')
const Config = require('@npmcli/config')
const chalk = require('chalk')
const which = require('which')
const fs = require('fs/promises')

Expand Down Expand Up @@ -42,12 +41,13 @@ class Npm {
#loadPromise = null
#title = 'npm'
#argvClean = []
#chalk = null
#logChalk = null
#noColorChalk = new chalk.Instance({ level: 0 })
#npmRoot = null
#warnedNonDashArg = false

#chalk = null
#logChalk = null
#noColorChalk = null

#outputBuffer = []
#logFile = new LogFile()
#display = new Display()
Expand Down Expand Up @@ -194,6 +194,13 @@ class Npm {

await this.time('npm:load:configload', () => this.config.load())

const { Chalk, supportsColor, supportsColorStderr } = await import('chalk')
this.#noColorChalk = new Chalk({ level: 0 })
this.#chalk = this.color ? new Chalk({ level: supportsColor.level })
: this.#noColorChalk
this.#logChalk = this.logColor ? new Chalk({ level: supportsColorStderr.level })
: this.#noColorChalk

// mkdir this separately since the logs dir can be set to
// a different location. if this fails, then we don't have
// a cache dir, but we don't want to fail immediately since
Expand Down Expand Up @@ -301,20 +308,10 @@ class Npm {
}

get chalk () {
if (!this.#chalk) {
this.#chalk = new chalk.Instance({
level: this.color ? chalk.level : 0,
})
}
return this.#chalk
}

get logChalk () {
if (!this.#logChalk) {
this.#logChalk = new chalk.Instance({
level: this.logColor ? chalk.stderr.level : 0,
})
}
return this.#logChalk
}

Expand Down
4 changes: 2 additions & 2 deletions lib/utils/explain-eresolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const explain = (expl, chalk, depth) => {
}

// generate a full verbose report and tell the user how to fix it
const report = (expl, chalk, noColor) => {
const report = (expl, chalk, noColorChalk) => {
const flags = [
expl.strictPeerDeps ? '--no-strict-peer-deps' : '',
'--force',
Expand All @@ -61,7 +61,7 @@ to accept an incorrect (and potentially broken) dependency resolution.`

return {
explanation: `${explain(expl, chalk, 4)}\n\n${fix}`,
file: `# npm resolution error report\n\n${explain(expl, noColor, Infinity)}\n\n${fix}`,
file: `# npm resolution error report\n\n${explain(expl, noColorChalk, Infinity)}\n\n${fix}`,
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/utils/reify-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const getAuditReport = (npm, report) => {
reporter,
...npm.flatOptions,
auditLevel,
chalk: npm.chalk,
})
if (npm.command === 'audit') {
process.exitCode = process.exitCode || res.exitCode
Expand Down
2 changes: 0 additions & 2 deletions node_modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
!/gauge
!/glob
!/graceful-fs
!/has-flag
!/has-unicode
!/has
!/hosted-git-info
Expand Down Expand Up @@ -284,7 +283,6 @@
!/string-width
!/strip-ansi-cjs
!/strip-ansi
!/supports-color
!/tar
!/tar/node_modules/
/tar/node_modules/*
Expand Down
2 changes: 1 addition & 1 deletion node_modules/chalk/license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

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:

Expand Down
59 changes: 36 additions & 23 deletions node_modules/chalk/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
{
"name": "chalk",
"version": "4.1.2",
"version": "5.2.0",
"description": "Terminal string styling done right",
"license": "MIT",
"repository": "chalk/chalk",
"funding": "https://github.com/chalk/chalk?sponsor=1",
"main": "source",
"type": "module",
"main": "./source/index.js",
"exports": "./source/index.js",
"imports": {
"#ansi-styles": "./source/vendor/ansi-styles/index.js",
"#supports-color": {
"node": "./source/vendor/supports-color/index.js",
"default": "./source/vendor/supports-color/browser.js"
}
},
"types": "./source/index.d.ts",
"engines": {
"node": ">=10"
"node": "^12.17.0 || ^14.13 || >=16.0.0"
},
"scripts": {
"test": "xo && nyc ava && tsd",
"test": "xo && c8 ava && tsd",
"bench": "matcha benchmark.js"
},
"files": [
"source",
"index.d.ts"
"!source/index.test-d.ts"
],
"keywords": [
"color",
Expand All @@ -25,7 +35,6 @@
"console",
"cli",
"string",
"str",
"ansi",
"style",
"styles",
Expand All @@ -40,29 +49,33 @@
"command-line",
"text"
],
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"devDependencies": {
"ava": "^2.4.0",
"coveralls": "^3.0.7",
"execa": "^4.0.0",
"import-fresh": "^3.1.0",
"@types/node": "^16.11.10",
"ava": "^3.15.0",
"c8": "^7.10.0",
"color-convert": "^2.0.1",
"execa": "^6.0.0",
"log-update": "^5.0.0",
"matcha": "^0.7.0",
"nyc": "^15.0.0",
"resolve-from": "^5.0.0",
"tsd": "^0.7.4",
"xo": "^0.28.2"
"tsd": "^0.19.0",
"xo": "^0.53.0",
"yoctodelay": "^2.0.0"
},
"xo": {
"rules": {
"unicorn/prefer-string-slice": "off",
"unicorn/prefer-includes": "off",
"@typescript-eslint/member-ordering": "off",
"no-redeclare": "off",
"unicorn/string-content": "off",
"unicorn/better-regex": "off"
"@typescript-eslint/consistent-type-imports": "off",
"@typescript-eslint/consistent-type-exports": "off",
"@typescript-eslint/consistent-type-definitions": "off"
}
},
"c8": {
"reporter": [
"text",
"lcov"
],
"exclude": [
"source/vendor"
]
}
}
Loading

0 comments on commit 060d587

Please sign in to comment.