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

fix: summary reporting #5031

Merged
merged 2 commits into from Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/lemon-numbers-hug.md
@@ -0,0 +1,6 @@
---
"@pnpm/default-reporter": patch
"pnpm": patch
---

Do not print a package with unchanged version in the installation summary.
1 change: 0 additions & 1 deletion packages/default-reporter/package.json
Expand Up @@ -11,7 +11,6 @@
"scripts": {
"start": "tsc --watch",
"lint": "eslint src/**/*.ts test/**/*.ts",
"pretty-test": "ts-node test | tap-diff",
"just-test-preview": "ts-node test --type-check",
"_test": "jest",
"test": "pnpm run compile && pnpm run _test",
Expand Down
37 changes: 22 additions & 15 deletions packages/default-reporter/src/reporterForClient/pkgsDiff.ts
Expand Up @@ -56,26 +56,33 @@ export default function (
scan((pkgsDiff, args) => {
const rootLog = args[0]
const deprecationSet = args[1] as Set<string>
let action: '-' | '+' | undefined
let log!: any // eslint-disable-line
if (rootLog['added']) {
pkgsDiff[rootLog['added'].dependencyType || 'nodeModulesOnly'][`+${rootLog['added'].name as string}`] = {
added: true,
deprecated: deprecationSet.has(rootLog['added'].id),
from: rootLog['added'].linkedFrom,
latest: rootLog['added'].latest,
name: rootLog['added'].name,
realName: rootLog['added'].realName,
version: rootLog['added'].version,
}
action = '+'
log = rootLog['added']
} else if (rootLog['removed']) {
action = '-'
log = rootLog['removed']
} else {
return pkgsDiff
}
if (rootLog['removed']) {
pkgsDiff[rootLog['removed'].dependencyType || 'nodeModulesOnly'][`-${rootLog['removed'].name as string}`] = {
added: false,
name: rootLog['removed'].name,
version: rootLog['removed'].version,
}
const depType = log.dependencyType || 'nodeModulesOnly'
const oppositeKey = `${action === '-' ? '+' : '-'}${log.name as string}`
const previous = pkgsDiff[depType][oppositeKey]
if (previous && previous.version === log.version) {
delete pkgsDiff[depType][oppositeKey]
return pkgsDiff
}
pkgsDiff[depType][`${action}${log.name as string}`] = {
added: action === '+',
deprecated: deprecationSet.has(log.id),
from: log.linkedFrom,
latest: log.latest,
name: log.name,
realName: log.realName,
version: log.version,
}
return pkgsDiff
}, {
dev: {},
Expand Down
20 changes: 19 additions & 1 deletion packages/default-reporter/test/index.ts
Expand Up @@ -34,7 +34,7 @@ const h1 = chalk.cyanBright

const EOL = '\n'

test('prints summary (of current package only)', (done) => {
test.only('prints summary (of current package only)', (done) => {
const prefix = '/home/jane/project'
const output$ = toOutput$({
context: {
Expand Down Expand Up @@ -98,6 +98,24 @@ test('prints summary (of current package only)', (done) => {
version: '0.1.0',
},
})
rootLogger.debug({
prefix,
removed: {
dependencyType: 'prod',
name: 'no-changes',
version: '1.0.0',
},
})
rootLogger.debug({
added: {
dependencyType: 'prod',
id: 'registry.npmjs.org/no-changes/2.0.0',
name: 'no-changes',
realName: 'no-changes',
version: '1.0.0',
},
prefix,
})
rootLogger.debug({
added: {
dependencyType: 'dev',
Expand Down