refactor: call installDeps directly in dedupe command handler (#6403)

* refactor: call installDeps directly in dedupe command handler

This allows the dedupe command to pass options to the `installDeps`
function that aren't available on the pnpm install command line or
config interface.

This better matches the setup in the `add` and `update` command
handlers, which also call `installDeps` directly. The previous setup
mimicked the `prune` command. Keeping the dedupe and install commands as
similar as possible was the original goal of having the dedupe command
reuse the install command handler, but this may not be necessary due to
how small the install command handler is. Small logic related to what
dependency fields to use was copied over.

There should be no expected behavior changes in this commit. The
`frozenLockfile` setting was not necessary to copy the `dedupe` option
skips all frozen lockfile logic.

* break: remove unused dedupe argument on install command handler

This becomes unnecessary now that the dedupe command handler no longer
calls the install command handler directly.
This commit is contained in:
Brandon Cheng
2023-04-16 08:55:46 -04:00
committed by GitHub
parent d43ccc44d2
commit 8e7a86dd95
4 changed files with 22 additions and 7 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-installation": patch
---
Internal refactor to call installDeps directly in the pnpm dedupe command handler. No behavior changes are expected with this refactor.

View File

@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-installation": major
---
Remove the `dedupe` option from `InstallCommandOptions`. This was not intentionally part of the public install command's API when it was added.

View File

@@ -1,7 +1,8 @@
import { docsUrl } from '@pnpm/cli-utils'
import { UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help'
import renderHelp from 'render-help'
import * as install from './install'
import { type InstallCommandOptions } from './install'
import { installDeps } from './installDeps'
export const rcOptionsTypes = cliOptionsTypes
@@ -27,11 +28,16 @@ export function help () {
})
}
export async function handler (
opts: install.InstallCommandOptions
) {
return install.handler({
export async function handler (opts: InstallCommandOptions) {
const include = {
dependencies: opts.production !== false,
devDependencies: opts.dev !== false,
optionalDependencies: opts.optional !== false,
}
return installDeps({
...opts,
dedupe: true,
})
include,
includeDirect: include,
}, [])
}

View File

@@ -296,7 +296,6 @@ export type InstallCommandOptions = Pick<Config,
pruneDirectDependencies?: boolean
pruneStore?: boolean
recursive?: boolean
dedupe?: boolean
saveLockfile?: boolean
workspace?: boolean
includeOnlyPackageFiles?: boolean