mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-11 18:50:16 -04:00
## 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
181 lines
5.3 KiB
TypeScript
181 lines
5.3 KiB
TypeScript
import { hashObject as _hashObject } from '@pnpm/crypto.object-hasher'
|
|
import { PnpmError } from '@pnpm/error'
|
|
import { addDependenciesToPackage, install, mutateModulesInSingleProject } from '@pnpm/installing.deps-installer'
|
|
import { prepareEmpty } from '@pnpm/prepare'
|
|
import type { PackageExtension, ProjectManifest, ProjectRootDir } from '@pnpm/types'
|
|
|
|
import {
|
|
testDefaults,
|
|
} from '../utils/index.js'
|
|
|
|
function hashObject (obj: Record<string, unknown>): string {
|
|
return `sha256-${_hashObject(obj)}`
|
|
}
|
|
|
|
test('manifests are extended with fields specified by packageExtensions', async () => {
|
|
const project = prepareEmpty()
|
|
|
|
const packageExtensions: Record<string, PackageExtension> = {
|
|
'is-positive': {
|
|
dependencies: {
|
|
'@pnpm.e2e/bar': '100.1.0',
|
|
},
|
|
},
|
|
}
|
|
const { updatedManifest: manifest } = await addDependenciesToPackage(
|
|
{},
|
|
['is-positive@1.0.0'],
|
|
testDefaults({ packageExtensions })
|
|
)
|
|
|
|
{
|
|
const lockfile = project.readLockfile()
|
|
expect(lockfile.snapshots['is-positive@1.0.0'].dependencies?.['@pnpm.e2e/bar']).toBe('100.1.0')
|
|
expect(lockfile.packageExtensionsChecksum).toStrictEqual(hashObject({
|
|
'is-positive': {
|
|
dependencies: {
|
|
'@pnpm.e2e/bar': '100.1.0',
|
|
},
|
|
},
|
|
}))
|
|
const currentLockfile = project.readCurrentLockfile()
|
|
expect(lockfile.packageExtensionsChecksum).toStrictEqual(currentLockfile.packageExtensionsChecksum)
|
|
}
|
|
|
|
// The lockfile is updated if the overrides are changed
|
|
packageExtensions['is-positive'].dependencies!['@pnpm.e2e/foobar'] = '100.0.0'
|
|
await mutateModulesInSingleProject({
|
|
manifest,
|
|
mutation: 'install',
|
|
rootDir: process.cwd() as ProjectRootDir,
|
|
}, testDefaults({ packageExtensions }))
|
|
|
|
{
|
|
const lockfile = project.readLockfile()
|
|
expect(lockfile.snapshots['is-positive@1.0.0'].dependencies?.['@pnpm.e2e/foobar']).toBe('100.0.0')
|
|
expect(lockfile.packageExtensionsChecksum).toStrictEqual(hashObject({
|
|
'is-positive': {
|
|
dependencies: {
|
|
'@pnpm.e2e/bar': '100.1.0',
|
|
'@pnpm.e2e/foobar': '100.0.0',
|
|
},
|
|
},
|
|
}))
|
|
const currentLockfile = project.readCurrentLockfile()
|
|
expect(lockfile.packageExtensionsChecksum).toStrictEqual(currentLockfile.packageExtensionsChecksum)
|
|
}
|
|
|
|
await mutateModulesInSingleProject({
|
|
manifest,
|
|
mutation: 'install',
|
|
rootDir: process.cwd() as ProjectRootDir,
|
|
}, testDefaults({ frozenLockfile: true, packageExtensions }))
|
|
|
|
{
|
|
const lockfile = project.readLockfile()
|
|
expect(lockfile.packageExtensionsChecksum).toStrictEqual(hashObject({
|
|
'is-positive': {
|
|
dependencies: {
|
|
'@pnpm.e2e/bar': '100.1.0',
|
|
'@pnpm.e2e/foobar': '100.0.0',
|
|
},
|
|
},
|
|
}))
|
|
const currentLockfile = project.readCurrentLockfile()
|
|
expect(lockfile.packageExtensionsChecksum).toStrictEqual(currentLockfile.packageExtensionsChecksum)
|
|
}
|
|
|
|
packageExtensions['is-positive'].dependencies!['@pnpm.e2e/bar'] = '100.0.1'
|
|
await expect(
|
|
mutateModulesInSingleProject({
|
|
manifest,
|
|
mutation: 'install',
|
|
rootDir: process.cwd() as ProjectRootDir,
|
|
}, testDefaults({ frozenLockfile: true, packageExtensions }))
|
|
).rejects.toThrow(
|
|
new PnpmError('LOCKFILE_CONFIG_MISMATCH',
|
|
'Cannot proceed with the frozen installation. The current "packageExtensionsChecksum" configuration doesn\'t match the value found in the lockfile'
|
|
)
|
|
)
|
|
})
|
|
|
|
test('packageExtensionsChecksum does not change regardless of keys order', async () => {
|
|
const project = prepareEmpty()
|
|
|
|
const packageExtensions1: Record<string, PackageExtension> = {
|
|
'is-odd': {
|
|
peerDependencies: {
|
|
'is-number': '*',
|
|
},
|
|
},
|
|
'is-even': {
|
|
peerDependencies: {
|
|
'is-number': '*',
|
|
},
|
|
},
|
|
}
|
|
|
|
const packageExtensions2: Record<string, PackageExtension> = {
|
|
'is-even': {
|
|
peerDependencies: {
|
|
'is-number': '*',
|
|
},
|
|
},
|
|
'is-odd': {
|
|
peerDependencies: {
|
|
'is-number': '*',
|
|
},
|
|
},
|
|
}
|
|
|
|
const manifest = (): ProjectManifest => ({
|
|
dependencies: {
|
|
'is-even': '*',
|
|
'is-odd': '*',
|
|
},
|
|
})
|
|
|
|
await install(manifest(), testDefaults({
|
|
packageExtensions: packageExtensions1,
|
|
}))
|
|
const lockfile1 = project.readLockfile()
|
|
const checksum1 = lockfile1.packageExtensionsChecksum
|
|
|
|
await install(manifest(), testDefaults({
|
|
packageExtensions: packageExtensions2,
|
|
}))
|
|
const lockfile2 = project.readLockfile()
|
|
const checksum2 = lockfile2.packageExtensionsChecksum
|
|
|
|
expect(checksum1).toBe(checksum2)
|
|
expect(checksum1).not.toBeFalsy()
|
|
})
|
|
|
|
test('manifests are patched by extensions from the compatibility database', async () => {
|
|
const project = prepareEmpty()
|
|
|
|
await addDependenciesToPackage(
|
|
{},
|
|
['debug@4.0.0'],
|
|
testDefaults()
|
|
)
|
|
|
|
const lockfile = project.readLockfile()
|
|
expect(lockfile.packages['debug@4.0.0'].peerDependenciesMeta?.['supports-color']?.optional).toBe(true)
|
|
})
|
|
|
|
test('manifests are not patched by extensions from the compatibility database when ignoreCompatibilityDb is true', async () => {
|
|
const project = prepareEmpty()
|
|
|
|
await addDependenciesToPackage(
|
|
{},
|
|
['debug@4.0.0'],
|
|
testDefaults({
|
|
ignoreCompatibilityDb: true,
|
|
})
|
|
)
|
|
|
|
const lockfile = project.readLockfile()
|
|
expect(lockfile.packages['debug@4.0.0'].peerDependenciesMeta).toBeUndefined()
|
|
})
|