diff --git a/.changeset/stale-colts-speak.md b/.changeset/stale-colts-speak.md new file mode 100644 index 0000000000..a1c5db6ccd --- /dev/null +++ b/.changeset/stale-colts-speak.md @@ -0,0 +1,5 @@ +--- +"@pnpm/plugin-commands-store": patch +--- + +fix: use correct path fix for integrity.json with git dependency diff --git a/packages/plugin-commands-store/src/storeStatus/index.ts b/packages/plugin-commands-store/src/storeStatus/index.ts index 12259a4ca1..25b27b896a 100644 --- a/packages/plugin-commands-store/src/storeStatus/index.ts +++ b/packages/plugin-commands-store/src/storeStatus/index.ts @@ -1,6 +1,9 @@ import { getFilePathInCafs, PackageFilesIndex } from '@pnpm/cafs' import { getContextForSingleImporter } from '@pnpm/get-context' -import { nameVerFromPkgSnapshot } from '@pnpm/lockfile-utils' +import { + nameVerFromPkgSnapshot, + packageIdFromSnapshot, +} from '@pnpm/lockfile-utils' import { streamParser } from '@pnpm/logger' import * as dp from 'dependency-path' import extendOptions, { @@ -32,20 +35,22 @@ export default async function (maybeOpts: StoreStatusOptions) { const pkgs = Object.keys(wantedLockfile.packages ?? {}) .filter((depPath) => !skipped.has(depPath)) .map((depPath) => { - const pkg = wantedLockfile.packages![depPath] + const pkgSnapshot = wantedLockfile.packages![depPath] + const id = packageIdFromSnapshot(depPath, pkgSnapshot, registries) return { depPath, - integrity: pkg.resolution['integrity'], + id, + integrity: pkgSnapshot.resolution['integrity'], pkgPath: dp.resolve(registries, depPath), - ...nameVerFromPkgSnapshot(depPath, pkg), + ...nameVerFromPkgSnapshot(depPath, pkgSnapshot), } }) const cafsDir = path.join(storeDir, 'files') - const modified = await pFilter(pkgs, async ({ integrity, pkgPath, depPath, name }) => { + const modified = await pFilter(pkgs, async ({ id, integrity, depPath, name }) => { const pkgIndexFilePath = integrity ? getFilePathInCafs(cafsDir, integrity, 'index') - : path.join(storeDir, pkgPath, 'integrity.json') + : path.join(storeDir, dp.depPathToFilename(id, opts.dir), 'integrity.json') const { files } = await loadJsonFile(pkgIndexFilePath) return (await dint.check(path.join(virtualStoreDir, dp.depPathToFilename(depPath, opts.dir), 'node_modules', name), files)) === false }, { concurrency: 8 }) diff --git a/packages/plugin-commands-store/test/storeStatus.ts b/packages/plugin-commands-store/test/storeStatus.ts index 566862188a..690bda004d 100644 --- a/packages/plugin-commands-store/test/storeStatus.ts +++ b/packages/plugin-commands-store/test/storeStatus.ts @@ -52,6 +52,7 @@ test('CLI does not fail when store status does not find modified packages', asyn 'is-positive@3.1.0', 'react@15.4.1', 'webpack@5.24.2', + 'koorchik/node-mole-rpc', ]) // store status does not fail on not installed optional dependencies await execa('node', [pnpmBin, 'add', 'not-compatible-with-any-os', '--save-optional', '--store-dir', storeDir, '--registry', REGISTRY, '--verify-store-integrity'])