mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-24 07:38:12 -05: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) {
|
||||
outputs.push(reportSummary(log$, {
|
||||
cmd: opts.cmd,
|
||||
cwd,
|
||||
env: opts.env,
|
||||
filterPkgsDiff: opts.filterPkgsDiff,
|
||||
|
||||
@@ -35,6 +35,7 @@ export function reportSummary (
|
||||
packageManifest: Rx.Observable<PackageManifestLog>
|
||||
},
|
||||
opts: {
|
||||
cmd: string
|
||||
cwd: string
|
||||
env: NodeJS.ProcessEnv
|
||||
filterPkgsDiff?: FilterPkgsDiff
|
||||
@@ -44,7 +45,7 @@ export function reportSummary (
|
||||
const pkgsDiff$ = getPkgsDiff(log$, { prefix: opts.cwd })
|
||||
|
||||
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(
|
||||
pkgsDiff$,
|
||||
@@ -69,7 +70,7 @@ export function reportSummary (
|
||||
msg += chalk.cyanBright(`${propertyByDependencyType[depType] as string}:`)
|
||||
}
|
||||
msg += EOL
|
||||
msg += _printDiffs(diffs)
|
||||
msg += _printDiffs(diffs, depType)
|
||||
msg += EOL
|
||||
} else if (opts.pnpmConfig?.[CONFIG_BY_DEP_TYPE[depType]] === false) {
|
||||
msg += EOL
|
||||
@@ -89,9 +90,12 @@ export type FilterPkgsDiff = (pkgsDiff: PackageDiff) => boolean
|
||||
|
||||
function printDiffs (
|
||||
opts: {
|
||||
cmd: string
|
||||
prefix: string
|
||||
pnpmConfig?: Config
|
||||
},
|
||||
pkgsDiff: PackageDiff[]
|
||||
pkgsDiff: PackageDiff[],
|
||||
depType: string
|
||||
) {
|
||||
// Sorts by alphabet then by removed/added
|
||||
// + ava 0.10.0
|
||||
@@ -119,6 +123,9 @@ function printDiffs (
|
||||
if (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
|
||||
}).join(EOL)
|
||||
return msg
|
||||
|
||||
Reference in New Issue
Block a user