feat(install): option to disable fast reinstall (#8977)

This commit is contained in:
Khải
2025-01-26 17:53:16 +07:00
committed by GitHub
parent acdf26d8cd
commit f3ffaed009
6 changed files with 17 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
---
"@pnpm/plugin-commands-installation": minor
"@pnpm/config": minor
"pnpm": minor
---
Added a new setting called `optimistic-repeat-install`. When enabled, a fast check will be performed before proceeding to installation. This way a repeat install or an install on a project with everything up-to-date becomes a lot faster. But some edge cases might arise, so we keep it disabled by default for now [#8977](https://github.com/pnpm/pnpm/pull/8977).

View File

@@ -45,6 +45,7 @@ export interface Config {
ignoreScripts?: boolean
ignoreCompatibilityDb?: boolean
includeWorkspaceRoot?: boolean
optimisticRepeatInstall?: boolean
save?: boolean
saveProd?: boolean
saveDev?: boolean

View File

@@ -147,6 +147,7 @@ export async function getConfig (opts: {
'hoist-workspace-packages': true,
'ignore-workspace-cycles': false,
'ignore-workspace-root-check': false,
'optimistic-repeat-install': false,
'inject-workspace-packages': false,
'link-workspace-packages': false,
'lockfile-include-tarball-url': false,

View File

@@ -42,6 +42,7 @@ export const types = Object.assign({
'ignore-workspace': Boolean,
'ignore-workspace-cycles': Boolean,
'ignore-workspace-root-check': Boolean,
'optimistic-repeat-install': Boolean,
'include-workspace-root': Boolean,
'inject-workspace-packages': Boolean,
'legacy-dir-filtering': Boolean,

View File

@@ -29,6 +29,7 @@ export function rcOptionsTypes (): Record<string, unknown> {
'https-proxy',
'ignore-pnpmfile',
'ignore-scripts',
'optimistic-repeat-install',
'link-workspace-packages',
'lockfile-dir',
'lockfile-directory',
@@ -114,6 +115,10 @@ For options that may be used with `-r`, see "pnpm help recursive"',
name: '--dev',
shortAlias: '-D',
},
{
description: 'Skip reinstall if the workspace state is up-to-date',
name: '--optimistic-repeat-install',
},
{
description: '`optionalDependencies` are not installed',
name: '--no-optional',

View File

@@ -65,6 +65,7 @@ export type InstallDepsOptions = Pick<Config,
| 'ignoreCurrentPrefs'
| 'ignorePnpmfile'
| 'ignoreScripts'
| 'optimisticRepeatInstall'
| 'linkWorkspacePackages'
| 'lockfileDir'
| 'lockfileOnly'
@@ -138,7 +139,7 @@ export async function installDeps (
opts: InstallDepsOptions,
params: string[]
): Promise<void> {
if (!opts.update && !opts.dedupe && params.length === 0) {
if (!opts.update && !opts.dedupe && params.length === 0 && opts.optimisticRepeatInstall) {
const { upToDate } = await checkDepsStatus({
...opts,
ignoreFilteredInstallCache: true,