feat: show linked dependencies in installation summary

ref https://github.com/pnpm/pnpm/issues/732
This commit is contained in:
Zoltan Kochan
2017-11-12 20:46:16 +02:00
parent 05220e3ebe
commit a953899409
5 changed files with 42 additions and 28 deletions

View File

@@ -27,6 +27,7 @@ const BIG_TARBALL_SIZE = 1024 * 1024 * 5 // 5 MB
const addedSign = chalk.green('+')
const removedSign = chalk.red('-')
const linkSign = chalk.magentaBright('#')
const hlValue = chalk.blue
const hlPkgId = chalk['whiteBright']
@@ -294,7 +295,11 @@ function printDiffs(pkgsDiff: PackageDiff[]) {
// + chalk 2.0.0
pkgsDiff.sort((a, b) => (a.name.localeCompare(b.name) * 10 + (Number(!b.added) - Number(!a.added))))
const msg = pkgsDiff.map((pkg) => {
let result = pkg.added ? addedSign : removedSign
let result = pkg.added
? addedSign
: pkg.linked
? linkSign
: removedSign
result += ` ${pkg.name}`
if (pkg.version) {
result += ` ${chalk.grey(pkg.version)}`
@@ -302,6 +307,9 @@ function printDiffs(pkgsDiff: PackageDiff[]) {
if (pkg.deprecated) {
result += ` ${chalk.red('deprecated')}`
}
if (pkg.linked) {
result += ` ${chalk.magentaBright('linked from')} ${chalk.grey(pkg.from || '???')}`
}
return result
}).join(EOL)
return msg

View File

@@ -6,10 +6,12 @@ import {
import xs, {Stream} from 'xstream'
export interface PackageDiff {
added: boolean,
from?: string,
name: string,
version?: string,
added: boolean,
deprecated?: boolean,
linked?: true,
}
interface Map<T> {
@@ -55,6 +57,15 @@ export default (log$: xs<Log>, deprecationLog$: xs<DeprecationLog>) => {
}
return pkgsDiff
}
if (rootLog['linked']) {
pkgsDiff[rootLog['linked'].dependencyType][`>${rootLog['linked'].name}`] = {
added: false,
from: rootLog['linked'].from,
linked: true,
name: rootLog['linked'].name,
}
return pkgsDiff
}
return pkgsDiff
}, {
dev: {},