mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-24 08:35:19 -04:00
feat: pnpm i a-module-already-in-dev-deps should show message (#7348)
close #926 --------- Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
6
.changeset/gorgeous-seas-listen.md
Normal file
6
.changeset/gorgeous-seas-listen.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@pnpm/default-reporter": patch
|
||||||
|
"pnpm": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
`pnpm add a-module-already-in-dev-deps` will show a message to notice the user that the package was not moved to "dependencies" [#926](https://github.com/pnpm/pnpm/issues/926) and fix [#7319](https://github.com/pnpm/pnpm/pull/7319)`
|
||||||
@@ -149,6 +149,7 @@ export function reporterForClient (
|
|||||||
|
|
||||||
if (!opts.isRecursive) {
|
if (!opts.isRecursive) {
|
||||||
outputs.push(reportSummary(log$, {
|
outputs.push(reportSummary(log$, {
|
||||||
|
cmd: opts.cmd,
|
||||||
cwd,
|
cwd,
|
||||||
env: opts.env,
|
env: opts.env,
|
||||||
filterPkgsDiff: opts.filterPkgsDiff,
|
filterPkgsDiff: opts.filterPkgsDiff,
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export function reportSummary (
|
|||||||
packageManifest: Rx.Observable<PackageManifestLog>
|
packageManifest: Rx.Observable<PackageManifestLog>
|
||||||
},
|
},
|
||||||
opts: {
|
opts: {
|
||||||
|
cmd: string
|
||||||
cwd: string
|
cwd: string
|
||||||
env: NodeJS.ProcessEnv
|
env: NodeJS.ProcessEnv
|
||||||
filterPkgsDiff?: FilterPkgsDiff
|
filterPkgsDiff?: FilterPkgsDiff
|
||||||
@@ -44,7 +45,7 @@ export function reportSummary (
|
|||||||
const pkgsDiff$ = getPkgsDiff(log$, { prefix: opts.cwd })
|
const pkgsDiff$ = getPkgsDiff(log$, { prefix: opts.cwd })
|
||||||
|
|
||||||
const summaryLog$ = log$.summary.pipe(take(1))
|
const summaryLog$ = log$.summary.pipe(take(1))
|
||||||
const _printDiffs = printDiffs.bind(null, { prefix: opts.cwd })
|
const _printDiffs = printDiffs.bind(null, { cmd: opts.cmd, prefix: opts.cwd, pnpmConfig: opts.pnpmConfig })
|
||||||
|
|
||||||
return Rx.combineLatest(
|
return Rx.combineLatest(
|
||||||
pkgsDiff$,
|
pkgsDiff$,
|
||||||
@@ -69,7 +70,7 @@ export function reportSummary (
|
|||||||
msg += chalk.cyanBright(`${propertyByDependencyType[depType] as string}:`)
|
msg += chalk.cyanBright(`${propertyByDependencyType[depType] as string}:`)
|
||||||
}
|
}
|
||||||
msg += EOL
|
msg += EOL
|
||||||
msg += _printDiffs(diffs)
|
msg += _printDiffs(diffs, depType)
|
||||||
msg += EOL
|
msg += EOL
|
||||||
} else if (opts.pnpmConfig?.[CONFIG_BY_DEP_TYPE[depType]] === false) {
|
} else if (opts.pnpmConfig?.[CONFIG_BY_DEP_TYPE[depType]] === false) {
|
||||||
msg += EOL
|
msg += EOL
|
||||||
@@ -89,9 +90,12 @@ export type FilterPkgsDiff = (pkgsDiff: PackageDiff) => boolean
|
|||||||
|
|
||||||
function printDiffs (
|
function printDiffs (
|
||||||
opts: {
|
opts: {
|
||||||
|
cmd: string
|
||||||
prefix: string
|
prefix: string
|
||||||
|
pnpmConfig?: Config
|
||||||
},
|
},
|
||||||
pkgsDiff: PackageDiff[]
|
pkgsDiff: PackageDiff[],
|
||||||
|
depType: string
|
||||||
) {
|
) {
|
||||||
// Sorts by alphabet then by removed/added
|
// Sorts by alphabet then by removed/added
|
||||||
// + ava 0.10.0
|
// + ava 0.10.0
|
||||||
@@ -119,6 +123,9 @@ function printDiffs (
|
|||||||
if (pkg.from) {
|
if (pkg.from) {
|
||||||
result += ` ${chalk.grey(`<- ${pkg.from && path.relative(opts.prefix, pkg.from) || '???'}`)}`
|
result += ` ${chalk.grey(`<- ${pkg.from && path.relative(opts.prefix, pkg.from) || '???'}`)}`
|
||||||
}
|
}
|
||||||
|
if (pkg.added && depType === 'dev' && opts.pnpmConfig?.saveDev === false && opts.cmd === 'add') {
|
||||||
|
result += `${chalk.yellow(' already in devDependencies, was not moved to dependencies.')}`
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
}).join(EOL)
|
}).join(EOL)
|
||||||
return msg
|
return msg
|
||||||
|
|||||||
Reference in New Issue
Block a user