diff --git a/.changeset/curly-starfishes-end.md b/.changeset/curly-starfishes-end.md new file mode 100644 index 00000000000..d08589c785f --- /dev/null +++ b/.changeset/curly-starfishes-end.md @@ -0,0 +1,7 @@ +--- +"@pnpm/headless": major +"@pnpm/core": patch +"pnpm": patch +--- + +Don't print "Lockfile is up-to-date" message before finishing all the lockfile checks [#6544](https://github.com/pnpm/pnpm/issues/6544). diff --git a/pkg-manager/core/src/install/index.ts b/pkg-manager/core/src/install/index.ts index 2b51ada00ba..d02e869aefa 100644 --- a/pkg-manager/core/src/install/index.ts +++ b/pkg-manager/core/src/install/index.ts @@ -32,7 +32,7 @@ import { type PatchFile, } from '@pnpm/lockfile-file' import { writePnpFile } from '@pnpm/lockfile-to-pnp' -import { extendProjectsWithTargetDirs } from '@pnpm/lockfile-utils' +import { extendProjectsWithTargetDirs, satisfiesPackageManifest } from '@pnpm/lockfile-utils' import { logger, globalInfo, streamParser } from '@pnpm/logger' import { getAllDependenciesFromManifest } from '@pnpm/manifest-utils' import { writeModulesManifest } from '@pnpm/modules-yaml' @@ -401,6 +401,25 @@ Note that in CI environments, this setting is enabled by default.`, } ) } + if (!opts.ignorePackageManifest) { + const _satisfiesPackageManifest = satisfiesPackageManifest.bind(null, { + autoInstallPeers: opts.autoInstallPeers, + excludeLinksFromLockfile: opts.excludeLinksFromLockfile, + }) + for (const { id, manifest, rootDir } of Object.values(ctx.projects)) { + const { satisfies, detailedReason } = _satisfiesPackageManifest(ctx.wantedLockfile.importers[id], manifest) + if (!satisfies) { + throw new PnpmError('OUTDATED_LOCKFILE', + `Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is not up to date with ` + + path.relative(opts.lockfileDir, path.join(rootDir, 'package.json')), { + hint: `Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile" + + Failure reason: + ${detailedReason ?? ''}`, + }) + } + } + } if (opts.lockfileOnly) { // The lockfile will only be changed if the workspace will have new projects with no dependencies. await writeWantedLockfile(ctx.lockfileDir, ctx.wantedLockfile) diff --git a/pkg-manager/headless/src/index.ts b/pkg-manager/headless/src/index.ts index 67117392497..75ceaa0e1af 100644 --- a/pkg-manager/headless/src/index.ts +++ b/pkg-manager/headless/src/index.ts @@ -13,7 +13,6 @@ import { statsLogger, summaryLogger, } from '@pnpm/core-loggers' -import { PnpmError } from '@pnpm/error' import { filterLockfileByImportersAndEngine, } from '@pnpm/filter-lockfile' @@ -36,7 +35,6 @@ import { writePnpFile } from '@pnpm/lockfile-to-pnp' import { extendProjectsWithTargetDirs, nameVerFromPkgSnapshot, - satisfiesPackageManifest, } from '@pnpm/lockfile-utils' import { type LogBase, @@ -194,26 +192,6 @@ export async function headlessInstall (opts: HeadlessOptions): Promise