Skip to content

Commit

Permalink
fix: don't print that lockfile is up to date when it is not
Browse files Browse the repository at this point in the history
close #6544
  • Loading branch information
zkochan committed May 21, 2023
1 parent 78e8392 commit 8a9fe53
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
7 changes: 7 additions & 0 deletions .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).
21 changes: 20 additions & 1 deletion pkg-manager/core/src/install/index.ts
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 0 additions & 22 deletions pkg-manager/headless/src/index.ts
Expand Up @@ -13,7 +13,6 @@ import {
statsLogger,
summaryLogger,
} from '@pnpm/core-loggers'
import { PnpmError } from '@pnpm/error'
import {
filterLockfileByImportersAndEngine,
} from '@pnpm/filter-lockfile'
Expand All @@ -36,7 +35,6 @@ import { writePnpFile } from '@pnpm/lockfile-to-pnp'
import {
extendProjectsWithTargetDirs,
nameVerFromPkgSnapshot,
satisfiesPackageManifest,
} from '@pnpm/lockfile-utils'
import {
type LogBase,
Expand Down Expand Up @@ -194,26 +192,6 @@ export async function headlessInstall (opts: HeadlessOptions): Promise<Installat
const publicHoistedModulesDir = rootModulesDir
const selectedProjects = Object.values(pick(opts.selectedProjectDirs, opts.allProjects))

if (!opts.ignorePackageManifest) {
const _satisfiesPackageManifest = satisfiesPackageManifest.bind(null, {
autoInstallPeers: opts.autoInstallPeers,
excludeLinksFromLockfile: opts.excludeLinksFromLockfile,
})
for (const { id, manifest, rootDir } of selectedProjects) {
const { satisfies, detailedReason } = _satisfiesPackageManifest(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(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 ?? ''}`,
})
}
}
}

const scriptsOpts = {
optional: false,
extraBinPaths: opts.extraBinPaths,
Expand Down

0 comments on commit 8a9fe53

Please sign in to comment.