diff --git a/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts b/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts index b51af8e9ea3..97472b735a4 100644 --- a/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts +++ b/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts @@ -6,8 +6,10 @@ import { type Registries } from '@pnpm/types' import loadJsonFile from 'load-json-file' export interface StrictRebuildOptions { + autoInstallPeers: boolean cacheDir: string childConcurrency: number + excludeLinksFromLockfile: boolean extraBinPaths: string[] extraEnv: Record lockfileDir: string diff --git a/lockfile/lockfile-file/src/read.ts b/lockfile/lockfile-file/src/read.ts index d07b7860b51..a4489e1757d 100644 --- a/lockfile/lockfile-file/src/read.ts +++ b/lockfile/lockfile-file/src/read.ts @@ -136,6 +136,8 @@ export function createLockfileObject ( importerIds: string[], opts: { lockfileVersion: number | string + autoInstallPeers: boolean + excludeLinksFromLockfile: boolean } ) { const importers = importerIds.reduce((acc, importerId) => { @@ -148,6 +150,8 @@ export function createLockfileObject ( return { importers, lockfileVersion: opts.lockfileVersion || LOCKFILE_VERSION, + autoInstallPeers: opts.autoInstallPeers, + excludeLinksFromLockfile: opts.excludeLinksFromLockfile, } } diff --git a/lockfile/lockfile-types/src/index.ts b/lockfile/lockfile-types/src/index.ts index acb12c072eb..cfd0135c348 100644 --- a/lockfile/lockfile-types/src/index.ts +++ b/lockfile/lockfile-types/src/index.ts @@ -12,6 +12,8 @@ export interface Lockfile { overrides?: Record packageExtensionsChecksum?: string patchedDependencies?: Record + autoInstallPeers?: boolean + excludeLinksFromLockfile?: boolean } export interface ProjectSnapshot { @@ -33,6 +35,8 @@ export interface LockfileV6 { overrides?: Record packageExtensionsChecksum?: string patchedDependencies?: Record + autoInstallPeers?: boolean + excludeLinksFromLockfile?: boolean } export interface ProjectSnapshotV6 { diff --git a/pkg-manager/core/src/getPeerDependencyIssues.ts b/pkg-manager/core/src/getPeerDependencyIssues.ts index 963af2059a6..728b5d2c91c 100644 --- a/pkg-manager/core/src/getPeerDependencyIssues.ts +++ b/pkg-manager/core/src/getPeerDependencyIssues.ts @@ -20,7 +20,7 @@ export type ListMissingPeersOptions = Partial | 'useGitBranchLockfile' | 'workspacePackages' > -& Pick +& Pick export async function getPeerDependencyIssues ( projects: ProjectOptions[], diff --git a/pkg-manager/core/src/install/index.ts b/pkg-manager/core/src/install/index.ts index cc05fe5513e..9d4bc6eaf41 100644 --- a/pkg-manager/core/src/install/index.ts +++ b/pkg-manager/core/src/install/index.ts @@ -319,6 +319,8 @@ export async function mutateModules ( : undefined let needsFullResolution = !maybeOpts.ignorePackageManifest && lockfileIsNotUpToDate(ctx.wantedLockfile, { + autoInstallPeers: opts.autoInstallPeers, + excludeLinksFromLockfile: opts.excludeLinksFromLockfile, overrides: opts.overrides, neverBuiltDependencies: opts.neverBuiltDependencies, onlyBuiltDependencies: opts.onlyBuiltDependencies, @@ -328,7 +330,19 @@ export async function mutateModules ( opts.fixLockfile || !ctx.wantedLockfile.lockfileVersion.toString().startsWith('6.') || opts.forceFullResolution + console.log('needsFullResolution', needsFullResolution) + console.log('lockf', lockfileIsNotUpToDate(ctx.wantedLockfile, { + autoInstallPeers: opts.autoInstallPeers, + excludeLinksFromLockfile: opts.excludeLinksFromLockfile, + overrides: opts.overrides, + neverBuiltDependencies: opts.neverBuiltDependencies, + onlyBuiltDependencies: opts.onlyBuiltDependencies, + packageExtensionsChecksum, + patchedDependencies, + })) if (needsFullResolution) { + ctx.wantedLockfile.autoInstallPeers = opts.autoInstallPeers + ctx.wantedLockfile.excludeLinksFromLockfile = opts.excludeLinksFromLockfile ctx.wantedLockfile.overrides = opts.overrides ctx.wantedLockfile.neverBuiltDependencies = opts.neverBuiltDependencies ctx.wantedLockfile.onlyBuiltDependencies = opts.onlyBuiltDependencies @@ -653,18 +667,25 @@ function lockfileIsNotUpToDate ( overrides, packageExtensionsChecksum, patchedDependencies, + autoInstallPeers, + excludeLinksFromLockfile, }: { neverBuiltDependencies?: string[] onlyBuiltDependencies?: string[] overrides?: Record packageExtensionsChecksum?: string patchedDependencies?: Record - }) { + autoInstallPeers?: boolean + excludeLinksFromLockfile?: boolean + } +) { return !equals(lockfile.overrides ?? {}, overrides ?? {}) || !equals((lockfile.neverBuiltDependencies ?? []).sort(), (neverBuiltDependencies ?? []).sort()) || !equals(onlyBuiltDependencies?.sort(), lockfile.onlyBuiltDependencies) || lockfile.packageExtensionsChecksum !== packageExtensionsChecksum || - !equals(lockfile.patchedDependencies ?? {}, patchedDependencies ?? {}) + !equals(lockfile.patchedDependencies ?? {}, patchedDependencies ?? {}) || + (lockfile.autoInstallPeers != null && lockfile.autoInstallPeers !== autoInstallPeers) || + (lockfile.excludeLinksFromLockfile != null && lockfile.excludeLinksFromLockfile !== excludeLinksFromLockfile) } export function createObjectChecksum (obj: unknown) { diff --git a/pkg-manager/core/src/link/options.ts b/pkg-manager/core/src/link/options.ts index 49b60f9abff..6dca21a1401 100644 --- a/pkg-manager/core/src/link/options.ts +++ b/pkg-manager/core/src/link/options.ts @@ -9,7 +9,9 @@ import { import { type ReporterFunction } from '../types' interface StrictLinkOptions { + autoInstallPeers: boolean binsDir: string + excludeLinksFromLockfile: boolean force: boolean forceSharedLockfile: boolean useLockfile: boolean diff --git a/pkg-manager/get-context/src/index.ts b/pkg-manager/get-context/src/index.ts index dcc737cfae9..ccb75320c66 100644 --- a/pkg-manager/get-context/src/index.ts +++ b/pkg-manager/get-context/src/index.ts @@ -71,6 +71,8 @@ interface HookOptions { } export interface GetContextOptions { + autoInstallPeers: boolean + excludeLinksFromLockfile: boolean allProjects: Array confirmModulesPurge?: boolean force: boolean @@ -178,6 +180,8 @@ export async function getContext ( storeDir: opts.storeDir, virtualStoreDir, ...await readLockfiles({ + autoInstallPeers: opts.autoInstallPeers, + excludeLinksFromLockfile: opts.excludeLinksFromLockfile, force: opts.force, forceSharedLockfile: opts.forceSharedLockfile, frozenLockfile: opts.frozenLockfile === true, @@ -406,6 +410,8 @@ export interface PnpmSingleContext { export async function getContextForSingleImporter ( manifest: ProjectManifest, opts: { + autoInstallPeers: boolean + excludeLinksFromLockfile: boolean force: boolean forceNewModules?: boolean forceSharedLockfile: boolean @@ -520,6 +526,8 @@ export async function getContextForSingleImporter ( storeDir, virtualStoreDir, ...await readLockfiles({ + autoInstallPeers: opts.autoInstallPeers, + excludeLinksFromLockfile: opts.excludeLinksFromLockfile, force: opts.force, forceSharedLockfile: opts.forceSharedLockfile, frozenLockfile: false, diff --git a/pkg-manager/get-context/src/readLockfiles.ts b/pkg-manager/get-context/src/readLockfiles.ts index d6ebe98de1f..d79bfdc3b62 100644 --- a/pkg-manager/get-context/src/readLockfiles.ts +++ b/pkg-manager/get-context/src/readLockfiles.ts @@ -26,6 +26,8 @@ export interface PnpmContext { export async function readLockfiles ( opts: { + autoInstallPeers: boolean + excludeLinksFromLockfile: boolean force: boolean forceSharedLockfile: boolean frozenLockfile: boolean @@ -103,7 +105,11 @@ export async function readLockfiles ( })() ) const files = await Promise.all(fileReads) - const sopts = { lockfileVersion: wantedLockfileVersion } + const sopts = { + autoInstallPeers: opts.autoInstallPeers, + excludeLinksFromLockfile: opts.excludeLinksFromLockfile, + lockfileVersion: wantedLockfileVersion, + } const importerIds = opts.projects.map((importer) => importer.id) const currentLockfile = files[1] ?? createLockfileObject(importerIds, sopts) for (const importerId of importerIds) { diff --git a/store/plugin-commands-store/src/storeStatus/extendStoreStatusOptions.ts b/store/plugin-commands-store/src/storeStatus/extendStoreStatusOptions.ts index 06db4e21074..13ae869cfb5 100644 --- a/store/plugin-commands-store/src/storeStatus/extendStoreStatusOptions.ts +++ b/store/plugin-commands-store/src/storeStatus/extendStoreStatusOptions.ts @@ -4,6 +4,8 @@ import { type Registries } from '@pnpm/types' import { type ReporterFunction } from '../types' export interface StrictStoreStatusOptions { + autoInstallPeers: boolean + excludeLinksFromLockfile: boolean lockfileDir: string dir: string storeDir: string