refactor: rename internal packages to @pnpm/<domain>.<leaf> convention (#10997)

## Summary

Rename all internal packages so their npm names follow the `@pnpm/<domain>.<leaf>` convention, matching their directory structure. Also rename directories to remove redundancy and improve clarity.

### Bulk rename (94 packages)

All `@pnpm/` packages now derive their name from their directory path using dot-separated segments. Exceptions: `packages/`, `__utils__/`, and `pnpm/artifacts/` keep leaf names only.

### Directory renames (removing redundant prefixes)

- `cli/cli-meta` → `cli/meta`, `cli/cli-utils` → `cli/utils`
- `config/config` → `config/reader`, `config/config-writer` → `config/writer`
- `fetching/fetching-types` → `fetching/types`
- `lockfile/lockfile-to-pnp` → `lockfile/to-pnp`
- `store/store-connection-manager` → `store/connection-manager`
- `store/store-controller-types` → `store/controller-types`
- `store/store-path` → `store/path`

### Targeted renames (clarity improvements)

- `deps/dependency-path` → `deps/path` (`@pnpm/deps.path`)
- `deps/calc-dep-state` → `deps/graph-hasher` (`@pnpm/deps.graph-hasher`)
- `deps/inspection/dependencies-hierarchy` → `deps/inspection/tree-builder` (`@pnpm/deps.inspection.tree-builder`)
- `bins/link-bins` → `bins/linker`, `bins/remove-bins` → `bins/remover`, `bins/package-bins` → `bins/resolver`
- `installing/get-context` → `installing/context`
- `store/package-store` → `store/controller`
- `pkg-manifest/manifest-utils` → `pkg-manifest/utils`

### Manifest reader/writer renames

- `workspace/read-project-manifest` → `workspace/project-manifest-reader` (`@pnpm/workspace.project-manifest-reader`)
- `workspace/write-project-manifest` → `workspace/project-manifest-writer` (`@pnpm/workspace.project-manifest-writer`)
- `workspace/read-manifest` → `workspace/workspace-manifest-reader` (`@pnpm/workspace.workspace-manifest-reader`)
- `workspace/manifest-writer` → `workspace/workspace-manifest-writer` (`@pnpm/workspace.workspace-manifest-writer`)

### Workspace package renames

- `workspace/find-packages` → `workspace/projects-reader`
- `workspace/find-workspace-dir` → `workspace/root-finder`
- `workspace/resolve-workspace-range` → `workspace/range-resolver`
- `workspace/filter-packages-from-dir` merged into `workspace/filter-workspace-packages` → `workspace/projects-filter`

### Domain moves

- `pkg-manifest/read-project-manifest` → `workspace/project-manifest-reader`
- `pkg-manifest/write-project-manifest` → `workspace/project-manifest-writer`
- `pkg-manifest/exportable-manifest` → `releasing/exportable-manifest`

### Scope

- 1206 files changed
- Updated: package.json names/deps, TypeScript imports, tsconfig references, changeset files, renovate.json, test fixtures, import ordering
This commit is contained in:
Zoltan Kochan
2026-03-17 21:50:40 +01:00
committed by GitHub
parent 7a304b17c4
commit 4a36b9a110
1305 changed files with 5574 additions and 6391 deletions

131
cli/utils/src/getConfig.ts Normal file
View File

@@ -0,0 +1,131 @@
import fs from 'node:fs'
import path from 'node:path'
import { formatWarn } from '@pnpm/cli.default-reporter'
import { packageManager } from '@pnpm/cli.meta'
import { resolveAndInstallConfigDeps } from '@pnpm/config.deps-installer'
import { type CliOptions, type Config, getConfig as _getConfig } from '@pnpm/config.reader'
import { requireHooks } from '@pnpm/hooks.pnpmfile'
import { createStoreController } from '@pnpm/store.connection-manager'
import type { ConfigDependencies } from '@pnpm/types'
import { lexCompare } from '@pnpm/util.lex-comparator'
export async function getConfig (
cliOptions: CliOptions,
opts: {
excludeReporter: boolean
globalDirShouldAllowWrite?: boolean
rcOptionsTypes: Record<string, unknown>
workspaceDir: string | undefined
checkUnknownSetting?: boolean
ignoreNonAuthSettingsFromLocal?: boolean
}
): Promise<Config> {
let { config, warnings } = await _getConfig({
cliOptions,
globalDirShouldAllowWrite: opts.globalDirShouldAllowWrite,
packageManager,
rcOptionsTypes: opts.rcOptionsTypes,
workspaceDir: opts.workspaceDir,
checkUnknownSetting: opts.checkUnknownSetting,
ignoreNonAuthSettingsFromLocal: opts.ignoreNonAuthSettingsFromLocal,
})
config.cliOptions = cliOptions
applyDerivedConfig(config)
if (opts.excludeReporter) {
delete config.reporter // This is a silly workaround because @pnpm/installing.deps-installer expects a function as opts.reporter
}
if (warnings.length > 0) {
console.warn(warnings.map((warning) => formatWarn(warning)).join('\n'))
}
return config
}
export async function installConfigDepsAndLoadHooks (config: Config): Promise<Config> {
if (config.configDependencies) {
const store = await createStoreController(config)
await resolveAndInstallConfigDeps(config.configDependencies, {
...config,
store: store.ctrl,
storeDir: store.dir,
rootDir: config.lockfileDir ?? config.rootProjectManifestDir,
})
}
if (!config.ignorePnpmfile) {
config.tryLoadDefaultPnpmfile = config.pnpmfile == null
const pnpmfiles = config.pnpmfile == null ? [] : Array.isArray(config.pnpmfile) ? config.pnpmfile : [config.pnpmfile]
if (config.configDependencies) {
const configModulesDir = path.join(config.lockfileDir ?? config.rootProjectManifestDir, 'node_modules/.pnpm-config')
pnpmfiles.unshift(...calcPnpmfilePathsOfPluginDeps(configModulesDir, config.configDependencies))
}
const { hooks, finders, resolvedPnpmfilePaths } = await requireHooks(config.lockfileDir ?? config.dir, {
globalPnpmfile: config.globalPnpmfile,
pnpmfiles,
tryLoadDefaultPnpmfile: config.tryLoadDefaultPnpmfile,
})
config.hooks = hooks
config.finders = finders
config.pnpmfile = resolvedPnpmfilePaths
if (config.hooks?.updateConfig) {
for (const updateConfig of config.hooks.updateConfig) {
const updateConfigResult = updateConfig(config)
config = updateConfigResult instanceof Promise ? await updateConfigResult : updateConfigResult // eslint-disable-line no-await-in-loop
}
}
}
return config
}
export function * calcPnpmfilePathsOfPluginDeps (configModulesDir: string, configDependencies: ConfigDependencies): Generator<string> {
for (const configDepName of Object.keys(configDependencies).sort(lexCompare)) {
if (isPluginName(configDepName)) {
const mjsPath = path.join(configModulesDir, configDepName, 'pnpmfile.mjs')
if (fs.existsSync(mjsPath)) {
yield mjsPath
} else {
yield path.join(configModulesDir, configDepName, 'pnpmfile.cjs')
}
}
}
}
function isPluginName (configDepName: string): boolean {
if (configDepName.startsWith('pnpm-plugin-')) return true
if (configDepName[0] !== '@') return false
return configDepName.startsWith('@pnpm/plugin-') || configDepName.includes('/pnpm-plugin-')
}
// Apply derived config settings (hoist, shamefullyHoist, symlink)
function applyDerivedConfig (config: Config): void {
if (config.hoist === false) {
delete config.hoistPattern
}
switch (config.shamefullyHoist) {
case false:
delete config.publicHoistPattern
break
case true:
config.publicHoistPattern = ['*']
break
default:
if (
(config.publicHoistPattern == null) ||
(config.publicHoistPattern === '') ||
(
Array.isArray(config.publicHoistPattern) &&
config.publicHoistPattern.length === 1 &&
config.publicHoistPattern[0] === ''
)
) {
delete config.publicHoistPattern
}
break
}
if (!config.symlink) {
delete config.hoistPattern
delete config.publicHoistPattern
}
}

13
cli/utils/src/index.ts Normal file
View File

@@ -0,0 +1,13 @@
import { packageManager } from '@pnpm/cli.meta'
export { calcPnpmfilePathsOfPluginDeps, getConfig, installConfigDepsAndLoadHooks } from './getConfig.js'
export * from './packageIsInstallable.js'
export * from './readDepNameCompletions.js'
export * from './readProjectManifest.js'
export * from './recursiveSummary.js'
export * from './style.js'
export function docsUrl (cmd: string): string {
const [pnpmMajorVersion] = packageManager.version.split('.')
return `https://pnpm.io/${pnpmMajorVersion}.x/cli/${cmd}`
}

View File

@@ -0,0 +1,46 @@
import { packageManager } from '@pnpm/cli.meta'
import { checkPackage, UnsupportedEngineError, type WantedEngine } from '@pnpm/config.package-is-installable'
import { logger } from '@pnpm/logger'
import type { SupportedArchitectures } from '@pnpm/types'
export function packageIsInstallable (
pkgPath: string,
pkg: {
packageManager?: string
engines?: WantedEngine
cpu?: string[]
os?: string[]
libc?: string[]
},
opts: {
packageManagerStrict?: boolean
packageManagerStrictVersion?: boolean
engineStrict?: boolean
nodeVersion?: string
supportedArchitectures?: SupportedArchitectures
}
): void {
const currentPnpmVersion = packageManager.name === 'pnpm'
? packageManager.version
: undefined
const err = checkPackage(pkgPath, pkg, {
nodeVersion: opts.nodeVersion,
pnpmVersion: currentPnpmVersion,
supportedArchitectures: opts.supportedArchitectures ?? {
os: ['current'],
cpu: ['current'],
libc: ['current'],
},
})
if (err === null) return
if (
(err instanceof UnsupportedEngineError && err.wanted.pnpm) ??
opts.engineStrict
) throw err
logger.warn({
message: `Unsupported ${
err instanceof UnsupportedEngineError ? 'engine' : 'platform'
}: wanted: ${JSON.stringify(err.wanted)} (current: ${JSON.stringify(err.current)})`,
prefix: pkgPath,
})
}

View File

@@ -0,0 +1,9 @@
import { getAllDependenciesFromManifest } from '@pnpm/pkg-manifest.utils'
import { readProjectManifest } from '@pnpm/workspace.project-manifest-reader'
export async function readDepNameCompletions (dir?: string): Promise<Array<{ name: string }>> {
const { manifest } = await readProjectManifest(dir ?? process.cwd())
return Object.keys(
getAllDependenciesFromManifest(manifest)
).map((name) => ({ name }))
}

View File

@@ -0,0 +1,53 @@
import type { ProjectManifest, SupportedArchitectures } from '@pnpm/types'
import * as utils from '@pnpm/workspace.project-manifest-reader'
import { packageIsInstallable } from './packageIsInstallable.js'
export interface ReadProjectManifestOpts {
engineStrict?: boolean
packageManagerStrict?: boolean
packageManagerStrictVersion?: boolean
nodeVersion?: string
supportedArchitectures?: SupportedArchitectures
}
interface BaseReadProjectManifestResult {
fileName: string
writeProjectManifest: (manifest: ProjectManifest, force?: boolean) => Promise<void>
}
export interface ReadProjectManifestResult extends BaseReadProjectManifestResult {
manifest: ProjectManifest
}
export async function readProjectManifest (
projectDir: string,
opts: ReadProjectManifestOpts = {}
): Promise<ReadProjectManifestResult> {
const { fileName, manifest, writeProjectManifest } = await utils.readProjectManifest(projectDir)
packageIsInstallable(projectDir, manifest as any, opts) // eslint-disable-line @typescript-eslint/no-explicit-any
return { fileName, manifest, writeProjectManifest }
}
export async function readProjectManifestOnly (
projectDir: string,
opts: ReadProjectManifestOpts = {}
): Promise<ProjectManifest> {
const manifest = await utils.readProjectManifestOnly(projectDir)
packageIsInstallable(projectDir, manifest as any, opts) // eslint-disable-line @typescript-eslint/no-explicit-any
return manifest
}
export interface TryReadProjectManifestResult extends BaseReadProjectManifestResult {
manifest: ProjectManifest | null
}
export async function tryReadProjectManifest (
projectDir: string,
opts: ReadProjectManifestOpts
): Promise<TryReadProjectManifestResult> {
const { fileName, manifest, writeProjectManifest } = await utils.tryReadProjectManifest(projectDir)
if (manifest == null) return { fileName, manifest, writeProjectManifest }
packageIsInstallable(projectDir, manifest as any, opts) // eslint-disable-line @typescript-eslint/no-explicit-any
return { fileName, manifest, writeProjectManifest }
}

View File

@@ -0,0 +1,33 @@
import { PnpmError } from '@pnpm/error'
interface ActionFailure {
status: 'failure'
duration?: number
prefix: string
message: string
error: Error
}
export type RecursiveSummary = Record<string, {
status: 'passed' | 'queued' | 'running' | 'skipped'
duration?: number
} | ActionFailure>
class RecursiveFailError extends PnpmError {
public readonly failures: ActionFailure[]
public readonly passes: number
constructor (command: string, recursiveSummary: RecursiveSummary, failures: ActionFailure[]) {
super('RECURSIVE_FAIL', `"${command}" failed in ${failures.length} packages`)
this.failures = failures
this.passes = Object.values(recursiveSummary).filter(({ status }) => status === 'passed').length
}
}
export function throwOnCommandFail (command: string, recursiveSummary: RecursiveSummary): void {
const failures = Object.values(recursiveSummary).filter(({ status }) => status === 'failure') as ActionFailure[]
if (failures.length > 0) {
throw new RecursiveFailError(command, recursiveSummary, failures)
}
}

31
cli/utils/src/style.ts Normal file
View File

@@ -0,0 +1,31 @@
import chalk from 'chalk'
export const TABLE_OPTIONS = {
border: {
topBody: '─',
topJoin: '┬',
topLeft: '┌',
topRight: '┐',
bottomBody: '─',
bottomJoin: '┴',
bottomLeft: '└',
bottomRight: '┘',
bodyJoin: '│',
bodyLeft: '│',
bodyRight: '│',
joinBody: '─',
joinJoin: '┼',
joinLeft: '├',
joinRight: '┤',
},
columns: {},
}
type BorderKey = keyof typeof TABLE_OPTIONS['border']
for (const [key, value] of Object.entries(TABLE_OPTIONS.border)) {
TABLE_OPTIONS.border[key as BorderKey] = chalk.grey(value)
}