mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-13 19:16:21 -04:00
* feat: add experimental use-inline-specifiers-lockfile-format
* fix(lockfile-file): check importers key for shared lockfile format
The `convertFromLockfileFileMutable` function reverts changes from
`normalizeLockfile` when not using the shared lockfile format.
- The non-shared lockfile format puts fields like `specifiers`,
`dependencies`, `devDependencies`, `optionalDependencies`, and
`dependenciesMeta` on the root of the lockfile. This is typically
the case for a repo not using pnpm workspaces.
- The shared lockfile format puts these under a `importers` block
scoped by a path.
The `use-inline-specifiers-lockfile-format` feature flag removes the
`specifiers` block in favor of putting each specifier next to the
resolved version within each `dependencies`, `devDependencies`, etc
block.
This means the `convertFromLockfileFileMutable` function can no longer
check for `specifiers` to detect the whether the "shared" format is
used. @zkochan suggested checking for `importers` instead, which should
have the same effect.
https://github.com/pnpm/pnpm/pull/5091#discussion_r929326835
* test(lockfile-file): add read & write test for useInlineSpecifiersFormat
@pnpm/lockfile-file
Read/write pnpm-lock.yaml files
Reads and writes the wanted (pnpm-lock.yaml) and current (node_modules/.pnpm-lock.yaml) lockfile files of pnpm.
Lockfile files are the state files of the node_modules installed via pnpm. They are like
the package-lock.json of npm or the yarn.lock of Yarn.
Install
pnpm add @pnpm/lockfile-file
API
readWantedLockfile(pkgPath, opts) => Promise<Lockfile>
Reads the pnpm-lock.yaml file from the root of the package.
Arguments
pkgPath- Path - the path to the projectopts.ignoreIncompatible- Boolean -falseby default. Iftrue, throws an error if the lockfile file format is not compatible with the current library.
readCurrentLockfile(virtualStoreDir, opts) => Promise<Lockfile>
Reads the lockfile file from <virtualStoreDir>/lock.yaml.
existsWantedLockfile(pkgPath) => Promise<Boolean>
Returns true if a pnpm-lock.yaml exists in the root of the package.
writeLockfiles(opts) => Promise<void>
Writes the wanted/current lockfile files. When they are empty, removes them.
Arguments
opts.wantedLockfileopts.wantedLockfileDiropts.currentLockfileopts.currentLockfileDir[opts.forceSharedFormat]
writeWantedLockfile(pkgPath, wantedLockfile) => Promise<void>
Writes the wanted lockfile file only. Sometimes it is needed just to update the wanted lockfile
without touching node_modules.
writeCurrentLockfile(virtualStoreDir, currentLockfile) => Promise<void>
Writes the current lockfile file only.