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

feature: explain - mark when dependency is bundled #2750

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 2 additions & 1 deletion lib/explain.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const explain = async (args) => {

const expls = []
for (const node of nodes) {
const { extraneous, dev, optional, devOptional, peer } = node
const { extraneous, dev, optional, devOptional, peer, inBundle } = node
const expl = node.explain()
if (extraneous)
expl.extraneous = true
Expand All @@ -39,6 +39,7 @@ const explain = async (args) => {
expl.optional = optional
expl.devOptional = devOptional
expl.peer = peer
expl.bundled = inBundle
}
expls.push(expl)
}
Expand Down
8 changes: 7 additions & 1 deletion lib/utils/explain-dep.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ const nocolor = {
yellow: s => s,
cyan: s => s,
magenta: s => s,
blue: s => s,
}

const explainNode = (node, depth, color) =>
printNode(node, color) +
explainDependents(node, depth, color)

const colorType = (type, color) => {
const { red, yellow, cyan, magenta } = color ? chalk : nocolor
const { red, yellow, cyan, magenta, blue } = color ? chalk : nocolor
const style = type === 'extraneous' ? red
: type === 'dev' ? yellow
: type === 'optional' ? cyan
: type === 'peer' ? magenta
: type === 'bundled' ? blue
: /* istanbul ignore next */ s => s
return style(type)
}
Expand All @@ -31,6 +33,7 @@ const printNode = (node, color) => {
dev,
optional,
peer,
bundled,
} = node
const { bold, dim } = color ? chalk : nocolor
const extra = []
Expand All @@ -46,6 +49,9 @@ const printNode = (node, color) => {
if (peer)
extra.push(' ' + bold(colorType('peer', color)))

if (bundled)
extra.push(' ' + bold(colorType('bundled', color)))

return `${bold(name)}@${bold(version)}${extra.join('')}` +
(location ? dim(`\n${location}`) : '')
}
Expand Down
2 changes: 2 additions & 0 deletions node_modules/@npmcli/arborist/lib/arborist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 23 additions & 1 deletion node_modules/@npmcli/arborist/lib/shrinkwrap.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions node_modules/@npmcli/arborist/lib/tracker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions node_modules/@npmcli/arborist/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading