refactor: remove unused @pnpm/fs.msgpack-file package and lockfile-directory setting (#11033)

Remove the @pnpm/fs.msgpack-file package which was never imported in
source code (only in its own tests). Also remove the deprecated
lockfile-directory CLI option alias — users should use lockfile-dir.
This commit is contained in:
Zoltan Kochan
2026-03-20 00:38:02 +01:00
committed by GitHub
parent a4a691a801
commit cd0e887db3
25 changed files with 1 additions and 359 deletions

View File

@@ -246,7 +246,6 @@ export interface Config extends AuthInfo, OptionsFromRootManifest {
export interface ConfigWithDeprecatedSettings extends Config {
globalPrefix?: string
proxy?: string
shamefullyFlatten?: boolean
}
export const PROJECT_CONFIG_FIELDS = [

View File

@@ -91,7 +91,6 @@ export const excludedPnpmKeys = [
'link-workspace-packages',
'lockfile',
'lockfile-dir',
'lockfile-directory',
'lockfile-include-tarball-url',
'lockfile-only',
'manage-package-manager-versions',
@@ -117,7 +116,6 @@ export const excludedPnpmKeys = [
'save-peer',
'save-workspace-protocol',
'script-shell',
'shamefully-flatten',
'shamefully-hoist',
'shared-workspace-lockfile',
'shell-emulator',

View File

@@ -119,9 +119,6 @@ export async function getConfig (opts: {
if (cliOptions['shamefully-hoist'] === true) {
throw new PnpmError('CONFIG_CONFLICT_HOIST', '--shamefully-hoist cannot be used with --no-hoist')
}
if (cliOptions['shamefully-flatten'] === true) {
throw new PnpmError('CONFIG_CONFLICT_HOIST', '--shamefully-flatten cannot be used with --no-hoist')
}
if (cliOptions['hoist-pattern']) {
throw new PnpmError('CONFIG_CONFLICT_HOIST', '--hoist-pattern cannot be used with --no-hoist')
}
@@ -522,10 +519,6 @@ export async function getConfig (opts: {
pnpmConfig.extraEnv['NODE_PATH'] = pathAbsolute(path.join(virtualStoreDir, 'node_modules'), cwd)
}
if (pnpmConfig.shamefullyFlatten) {
warnings.push('The "shamefully-flatten" setting has been renamed to "shamefully-hoist". Also, in most cases you won\'t need "shamefully-hoist". Since v4, a semistrict node_modules structure is on by default (via hoist-pattern=[*]).')
pnpmConfig.shamefullyHoist = true
}
if (!pnpmConfig.cacheDir) {
pnpmConfig.cacheDir = getCacheDir(process)
}

View File

@@ -58,7 +58,6 @@ export const pnpmTypes = {
'link-workspace-packages': [Boolean, 'deep'],
lockfile: Boolean,
'lockfile-dir': String,
'lockfile-directory': String, // TODO: deprecate
'lockfile-include-tarball-url': Boolean,
'lockfile-only': Boolean,
loglevel: ['silent', 'error', 'warn', 'info', 'debug'],
@@ -100,7 +99,6 @@ export const pnpmTypes = {
'save-catalog-name': String,
'save-workspace-protocol': Boolean,
'script-shell': String,
'shamefully-flatten': Boolean,
'shamefully-hoist': Boolean,
'shared-workspace-lockfile': Boolean,
'shell-emulator': Boolean,

View File

@@ -534,26 +534,6 @@ test('extraBinPaths', async () => {
}
})
test('convert shamefully-flatten to hoist-pattern=* and warn', async () => {
const { config, warnings } = await getConfig({
cliOptions: {
'shamefully-flatten': true,
},
packageManager: {
name: 'pnpm',
version: '1.0.0',
},
})
expect(config.hoistPattern).toStrictEqual(['*'])
expect(config.shamefullyHoist).toBeTruthy()
expect(warnings).toStrictEqual([
'The "shamefully-flatten" setting has been renamed to "shamefully-hoist". ' +
'Also, in most cases you won\'t need "shamefully-hoist". ' +
'Since v4, a semistrict node_modules structure is on by default (via hoist-pattern=[*]).',
])
})
// hoist → hoistPattern processing is done in @pnpm/cli.utils
test('hoist-pattern is unchanged if --no-hoist used', async () => {
const { config } = await getConfig({
@@ -586,22 +566,6 @@ test('throw error if --no-hoist is used with --shamefully-hoist', async () => {
})
})
test('throw error if --no-hoist is used with --shamefully-flatten', async () => {
await expect(getConfig({
cliOptions: {
hoist: false,
'shamefully-flatten': true,
},
packageManager: {
name: 'pnpm',
version: '1.0.0',
},
})).rejects.toMatchObject({
code: 'ERR_PNPM_CONFIG_CONFLICT_HOIST',
message: '--shamefully-flatten cannot be used with --no-hoist',
})
})
test('throw error if --no-hoist is used with --hoist-pattern', async () => {
await expect(getConfig({
cliOptions: {

View File

@@ -1,40 +0,0 @@
# @pnpm/fs.msgpack-file
> MessagePack file serialization utilities for pnpm
[![npm version](https://img.shields.io/npm/v/@pnpm/fs.msgpack-file.svg)](https://www.npmjs.com/package/@pnpm/fs.msgpack-file)
## Installation
```sh
pnpm add @pnpm/fs.msgpack-file
```
## Usage
```typescript
import {
readMsgpackFile,
readMsgpackFileSync,
writeMsgpackFile,
writeMsgpackFileSync,
} from '@pnpm/fs.msgpack-file'
// Async
await writeMsgpackFile('data.mpk', { foo: 'bar' })
const data = await readMsgpackFile('data.mpk')
// Sync
writeMsgpackFileSync('data.mpk', { foo: 'bar' })
const data = readMsgpackFileSync('data.mpk')
```
## Features
- Uses [msgpackr](https://github.com/kriszyp/msgpackr) for fast MessagePack serialization
- Supports `Map` and `Set` types natively
- Record structure optimization enabled for 2-3x faster decoding
## License
MIT

View File

@@ -1,48 +0,0 @@
{
"name": "@pnpm/fs.msgpack-file",
"version": "1100.0.0-0",
"description": "Msgpack serialization utilities for pnpm cache files",
"keywords": [
"pnpm",
"pnpm11"
],
"license": "MIT",
"funding": "https://opencollective.com/pnpm",
"repository": "https://github.com/pnpm/pnpm/tree/main/fs/msgpack-file",
"homepage": "https://github.com/pnpm/pnpm/tree/main/fs/msgpack-file#readme",
"bugs": {
"url": "https://github.com/pnpm/pnpm/issues"
},
"type": "module",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"exports": {
".": "./lib/index.js"
},
"files": [
"lib",
"!*.map"
],
"scripts": {
"compile": "tsgo --build && pnpm run lint --fix",
"watch": "tsgo --build --watch",
"prepublishOnly": "pnpm run compile",
"test": "pnpm run compile && pnpm run _test",
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
"_test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
},
"dependencies": {
"@pnpm/fs.graceful-fs": "workspace:*",
"msgpackr": "catalog:"
},
"devDependencies": {
"@pnpm/fs.msgpack-file": "workspace:*",
"tempy": "catalog:"
},
"engines": {
"node": ">=22.13"
},
"jest": {
"preset": "@pnpm/jest-config"
}
}

View File

@@ -1,45 +0,0 @@
import gfs from '@pnpm/fs.graceful-fs'
import { Packr } from 'msgpackr'
/**
* Create a Packr instance with record structure optimization enabled.
* This provides 2-3x faster decoding performance by reusing object structures
* and using integer keys instead of string property names.
*/
const packr = new Packr({
useRecords: true,
// moreTypes: true enables better type preservation for undefined, etc.
moreTypes: true,
})
/**
* Write data to a file in msgpack format (synchronous)
*/
export function writeMsgpackFileSync (filePath: string, data: unknown): void {
const buffer = packr.pack(data)
gfs.writeFileSync(filePath, buffer)
}
/**
* Read msgpack data from a file (synchronous)
*/
export function readMsgpackFileSync<T> (filePath: string): T {
const buffer = gfs.readFileSync(filePath)
return packr.unpack(buffer) as T
}
/**
* Read msgpack data from a file (async)
*/
export async function readMsgpackFile<T> (filePath: string): Promise<T> {
const buffer = await gfs.readFile(filePath)
return packr.unpack(buffer) as T
}
/**
* Write data to a file in msgpack format (async)
*/
export async function writeMsgpackFile (filePath: string, data: unknown): Promise<void> {
const buffer = packr.pack(data)
await gfs.writeFile(filePath, buffer)
}

View File

@@ -1,89 +0,0 @@
import fs from 'node:fs'
import {
readMsgpackFile,
readMsgpackFileSync,
writeMsgpackFile,
writeMsgpackFileSync,
} from '@pnpm/fs.msgpack-file'
import { temporaryDirectory } from 'tempy'
describe('msgpack-file', () => {
let tmpDir: string
beforeEach(() => {
tmpDir = temporaryDirectory()
})
test('writeFileSync and readFileSync', () => {
const filePath = `${tmpDir}/test.mpk`
const data = {
foo: 'bar',
baz: 123,
nested: {
a: 1,
b: 2,
},
}
writeMsgpackFileSync(filePath, data)
expect(fs.existsSync(filePath)).toBe(true)
const readData = readMsgpackFileSync(filePath)
expect(readData).toEqual(data)
})
test('writeFile and readFile (async)', async () => {
const filePath = `${tmpDir}/test-async.mpk`
const data = {
foo: 'bar',
baz: 123,
nested: {
a: 1,
b: 2,
},
}
await writeMsgpackFile(filePath, data)
expect(fs.existsSync(filePath)).toBe(true)
const readData = await readMsgpackFile(filePath)
expect(readData).toEqual(data)
})
test('it should support Map and Set serialization (moreTypes: true)', () => {
const filePath = `${tmpDir}/map-set.mpk`
const data = {
map: new Map([['key1', 'value1'], ['key2', 'value2']]),
set: new Set([1, 2, 3, 3]),
}
writeMsgpackFileSync(filePath, data)
const readData = readMsgpackFileSync<any>(filePath) // eslint-disable-line @typescript-eslint/no-explicit-any
expect(readData.map).toBeInstanceOf(Map)
expect(readData.map.get('key1')).toBe('value1')
expect(readData.set).toBeInstanceOf(Set)
expect(readData.set.has(1)).toBe(true)
expect(readData.set.size).toBe(3)
})
test('it should use record structures for optimization (useRecords: true)', () => {
const filePath = `${tmpDir}/records.mpk`
const structure = { name: 'pkg', version: '1.0.0' }
const data = [
structure,
structure,
structure,
]
writeMsgpackFileSync(filePath, data)
const readData = readMsgpackFileSync<any>(filePath) // eslint-disable-line @typescript-eslint/no-explicit-any
expect(readData).toHaveLength(3)
expect(readData[0]).toEqual(structure)
expect(readData[2]).toEqual(structure)
})
})

View File

@@ -1,18 +0,0 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": false,
"outDir": "../node_modules/.test.lib",
"rootDir": "..",
"isolatedModules": true
},
"include": [
"**/*.ts",
"../../../__typings__/**/*.d.ts"
],
"references": [
{
"path": ".."
}
]
}

View File

@@ -1,16 +0,0 @@
{
"extends": "@pnpm/tsconfig",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/**/*.ts",
"../../__typings__/**/*.d.ts"
],
"references": [
{
"path": "../graceful-fs"
}
]
}

View File

@@ -1,8 +0,0 @@
{
"extends": "./tsconfig.json",
"include": [
"src/**/*.ts",
"test/**/*.ts",
"../../__typings__/**/*.d.ts"
]
}

View File

@@ -47,7 +47,6 @@ export function rcOptionsTypes (): Record<string, unknown> {
'libc',
'link-workspace-packages',
'lockfile-dir',
'lockfile-directory',
'lockfile-only',
'lockfile',
'modules-dir',
@@ -72,7 +71,6 @@ export function rcOptionsTypes (): Record<string, unknown> {
'save-prefix',
'save-prod',
'save-workspace-protocol',
'shamefully-flatten',
'shamefully-hoist',
'shared-workspace-lockfile',
'side-effects-cache-readonly',

View File

@@ -37,7 +37,6 @@ export function rcOptionsTypes (): Record<string, unknown> {
'libc',
'link-workspace-packages',
'lockfile-dir',
'lockfile-directory',
'lockfile-only',
'lockfile',
'merge-git-branch-lockfiles',
@@ -57,7 +56,6 @@ export function rcOptionsTypes (): Record<string, unknown> {
'reporter',
'save-workspace-protocol',
'scripts-prepend-node-path',
'shamefully-flatten',
'shamefully-hoist',
'shared-workspace-lockfile',
'side-effects-cache-readonly',

View File

@@ -52,7 +52,6 @@ export function rcOptionsTypes (): Record<string, unknown> {
'global-pnpmfile',
'global',
'lockfile-dir',
'lockfile-directory',
'lockfile-only',
'lockfile',
'node-linker',

View File

@@ -42,7 +42,6 @@ export function rcOptionsTypes (): Record<string, unknown> {
'ignore-pnpmfile',
'ignore-scripts',
'lockfile-dir',
'lockfile-directory',
'lockfile-only',
'lockfile',
'lockfile-include-tarball-url',
@@ -64,7 +63,6 @@ export function rcOptionsTypes (): Record<string, unknown> {
'save-prefix',
'save-workspace-protocol',
'scripts-prepend-node-path',
'shamefully-flatten',
'shamefully-hoist',
'shared-workspace-lockfile',
'side-effects-cache-readonly',

View File

@@ -127,7 +127,6 @@
"@jest/globals": "catalog:",
"@pnpm/assert-project": "workspace:*",
"@pnpm/assert-store": "workspace:*",
"@pnpm/fs.msgpack-file": "workspace:*",
"@pnpm/installing.deps-installer": "workspace:*",
"@pnpm/lockfile.types": "workspace:*",
"@pnpm/logger": "workspace:*",

View File

@@ -90,9 +90,6 @@
{
"path": "../../exec/lifecycle"
},
{
"path": "../../fs/msgpack-file"
},
{
"path": "../../fs/read-modules-dir"
},

View File

@@ -63,7 +63,6 @@
},
"devDependencies": {
"@jest/globals": "catalog:",
"@pnpm/fs.msgpack-file": "workspace:*",
"@pnpm/installing.client": "workspace:*",
"@pnpm/installing.package-requester": "workspace:*",
"@pnpm/logger": "workspace:*",

View File

@@ -39,9 +39,6 @@
{
"path": "../../fs/graceful-fs"
},
{
"path": "../../fs/msgpack-file"
},
{
"path": "../../hooks/types"
},

25
pnpm-lock.yaml generated
View File

@@ -4443,22 +4443,6 @@ importers:
specifier: workspace:*
version: 'link:'
fs/msgpack-file:
dependencies:
'@pnpm/fs.graceful-fs':
specifier: workspace:*
version: link:../graceful-fs
msgpackr:
specifier: 'catalog:'
version: 1.11.8
devDependencies:
'@pnpm/fs.msgpack-file':
specifier: workspace:*
version: 'link:'
tempy:
specifier: 'catalog:'
version: 3.0.0
fs/packlist:
dependencies:
npm-packlist:
@@ -5303,9 +5287,6 @@ importers:
'@pnpm/assert-store':
specifier: workspace:*
version: link:../../__utils__/assert-store
'@pnpm/fs.msgpack-file':
specifier: workspace:*
version: link:../../fs/msgpack-file
'@pnpm/installing.deps-installer':
specifier: workspace:*
version: 'link:'
@@ -6059,9 +6040,6 @@ importers:
'@jest/globals':
specifier: 'catalog:'
version: 30.3.0
'@pnpm/fs.msgpack-file':
specifier: workspace:*
version: link:../../fs/msgpack-file
'@pnpm/installing.client':
specifier: workspace:*
version: link:../client
@@ -7143,9 +7121,6 @@ importers:
'@pnpm/exec.run-npm':
specifier: workspace:*
version: link:../exec/run-npm
'@pnpm/fs.msgpack-file':
specifier: workspace:*
version: link:../fs/msgpack-file
'@pnpm/hooks.pnpmfile':
specifier: workspace:*
version: link:../hooks/pnpmfile

View File

@@ -102,7 +102,6 @@
"@pnpm/error": "workspace:*",
"@pnpm/exec.commands": "workspace:*",
"@pnpm/exec.run-npm": "workspace:*",
"@pnpm/fs.msgpack-file": "workspace:*",
"@pnpm/installing.client": "workspace:*",
"@pnpm/installing.commands": "workspace:*",
"@pnpm/installing.env-installer": "workspace:*",

View File

@@ -9,9 +9,7 @@ import {
import { shorthands as universalShorthands } from './shorthands.js'
const RENAMED_OPTIONS = {
'lockfile-directory': 'lockfile-dir',
prefix: 'dir',
'shrinkwrap-directory': 'lockfile-dir',
store: 'store-dir',
}

View File

@@ -111,7 +111,7 @@ test('install from any location via the --prefix flag', async () => {
test('install with external lockfile directory', async () => {
const project = prepare()
await execPnpm(['install', 'is-positive', '--lockfile-directory', path.resolve('..')])
await execPnpm(['install', 'is-positive', '--lockfile-dir', path.resolve('..')])
project.has('is-positive')

View File

@@ -98,9 +98,6 @@
{
"path": "../exec/run-npm"
},
{
"path": "../fs/msgpack-file"
},
{
"path": "../hooks/pnpmfile"
},