feat: resolution-only (#6411)

close #1944
ref #4679
This commit is contained in:
Zoltan Kochan
2023-04-17 22:06:53 +03:00
committed by GitHub
parent 31ca5a218b
commit 71a3ee77b9
5 changed files with 26 additions and 4 deletions

View File

@@ -0,0 +1,7 @@
---
"@pnpm/plugin-commands-installation": minor
"@pnpm/core": minor
"pnpm": minor
---
`pnpm install --resolution-only` re-runs resolution to print out any peer dependency issues [#6411](https://github.com/pnpm/pnpm/pull/6411).

View File

@@ -35,6 +35,7 @@ export interface StrictInstallOptions {
mergeGitBranchLockfiles: boolean
linkWorkspacePackagesDepth: number
lockfileOnly: boolean
forceFullResolution: boolean
fixLockfile: boolean
dedupe: boolean
ignoreCompatibilityDb: boolean
@@ -142,6 +143,7 @@ const defaults = async (opts: InstallOptions) => {
enablePnp: false,
engineStrict: false,
force: false,
forceFullResolution: false,
forceSharedLockfile: false,
frozenLockfile: false,
hoistPattern: undefined,

View File

@@ -318,7 +318,8 @@ export async function mutateModules (
patchedDependencies,
}) ||
opts.fixLockfile ||
!ctx.wantedLockfile.lockfileVersion.toString().startsWith('6.')
!ctx.wantedLockfile.lockfileVersion.toString().startsWith('6.') ||
opts.forceFullResolution
if (needsFullResolution) {
ctx.wantedLockfile.overrides = opts.overrides
ctx.wantedLockfile.neverBuiltDependencies = opts.neverBuiltDependencies

View File

@@ -6,7 +6,7 @@ import { type CreateStoreControllerOptions } from '@pnpm/store-connection-manage
import { isCI } from 'ci-info'
import pick from 'ramda/src/pick'
import renderHelp from 'render-help'
import { installDeps } from './installDeps'
import { installDeps, type InstallDepsOptions } from './installDeps'
export function rcOptionsTypes () {
return pick([
@@ -74,6 +74,7 @@ export const cliOptionsTypes = () => ({
...rcOptionsTypes(),
...pick(['force'], allTypes),
'fix-lockfile': Boolean,
'resolution-only': Boolean,
recursive: Boolean,
})
@@ -228,6 +229,10 @@ Install all optionalDependencies even they don\'t satisfy the current environmen
description: 'Only use the side effects cache if present, do not create it for new packages',
name: '--side-effects-cache-readonly',
},
{
description: 'Re-runs resolution: useful for printing out peer dependency issues',
name: '--resolution-only',
},
...UNIVERSAL_OPTIONS,
],
},
@@ -296,6 +301,7 @@ export type InstallCommandOptions = Pick<Config,
pruneDirectDependencies?: boolean
pruneStore?: boolean
recursive?: boolean
resolutionOnly?: boolean
saveLockfile?: boolean
workspace?: boolean
includeOnlyPackageFiles?: boolean
@@ -309,12 +315,17 @@ export async function handler (
devDependencies: opts.dev !== false,
optionalDependencies: opts.optional !== false,
}
return installDeps({
const installDepsOptions: InstallDepsOptions = {
...opts,
frozenLockfileIfExists: isCI && !opts.lockfileOnly &&
typeof opts.rawLocalConfig['frozen-lockfile'] === 'undefined' &&
typeof opts.rawLocalConfig['prefer-frozen-lockfile'] === 'undefined',
include,
includeDirect: include,
}, [])
}
if (opts.resolutionOnly) {
installDepsOptions.lockfileOnly = true
installDepsOptions.forceFullResolution = true
}
return installDeps(installDepsOptions, [])
}

View File

@@ -85,6 +85,7 @@ export type InstallDepsOptions = Pick<Config,
original: string[]
}
allowNew?: boolean
forceFullResolution?: boolean
frozenLockfileIfExists?: boolean
include?: IncludedDependencies
includeDirect?: IncludedDependencies