mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-27 10:30:58 -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
167 lines
5.4 KiB
TypeScript
167 lines
5.4 KiB
TypeScript
import { ENGINE_NAME } from '@pnpm/constants'
|
|
import { hashObject, hashObjectWithoutSorting } from '@pnpm/crypto.object-hasher'
|
|
import { calcDepState, calcGraphNodeHash } from '@pnpm/deps.graph-hasher'
|
|
import type { DepPath, PkgIdWithPatchHash } from '@pnpm/types'
|
|
|
|
const depsGraph = {
|
|
'foo@1.0.0': {
|
|
pkgIdWithPatchHash: 'foo@1.0.0' as PkgIdWithPatchHash,
|
|
resolution: {
|
|
integrity: '000',
|
|
},
|
|
children: {
|
|
bar: 'bar@1.0.0',
|
|
},
|
|
},
|
|
'bar@1.0.0': {
|
|
pkgIdWithPatchHash: 'bar@1.0.0' as PkgIdWithPatchHash,
|
|
resolution: {
|
|
integrity: '001',
|
|
},
|
|
children: {
|
|
foo: 'foo@1.0.0',
|
|
},
|
|
},
|
|
}
|
|
|
|
test('calcDepState()', () => {
|
|
expect(calcDepState(depsGraph, {}, 'foo@1.0.0', {
|
|
includeDepGraphHash: true,
|
|
})).toBe(`${ENGINE_NAME};deps=${hashObject({
|
|
id: 'foo@1.0.0:000',
|
|
deps: {
|
|
bar: hashObject({
|
|
id: 'bar@1.0.0:001',
|
|
deps: {
|
|
foo: hashObject({
|
|
id: 'foo@1.0.0:000',
|
|
deps: {},
|
|
}),
|
|
},
|
|
}),
|
|
},
|
|
})}`)
|
|
})
|
|
|
|
test('calcDepState() when scripts are ignored', () => {
|
|
expect(calcDepState(depsGraph, {}, 'foo@1.0.0', {
|
|
includeDepGraphHash: false,
|
|
})).toBe(ENGINE_NAME)
|
|
})
|
|
|
|
describe('calcGraphNodeHash', () => {
|
|
const graphNodeGraph = {
|
|
'foo@1.0.0': {
|
|
children: { bar: 'bar@1.0.0' as DepPath },
|
|
pkgIdWithPatchHash: 'foo@1.0.0' as PkgIdWithPatchHash,
|
|
resolution: { integrity: '000' },
|
|
},
|
|
'bar@1.0.0': {
|
|
children: {},
|
|
pkgIdWithPatchHash: 'bar@1.0.0' as PkgIdWithPatchHash,
|
|
resolution: { integrity: '001' },
|
|
},
|
|
'native@1.0.0': {
|
|
children: {},
|
|
pkgIdWithPatchHash: 'native@1.0.0' as PkgIdWithPatchHash,
|
|
resolution: { integrity: '002' },
|
|
},
|
|
'depends-on-native@1.0.0': {
|
|
children: { native: 'native@1.0.0' as DepPath },
|
|
pkgIdWithPatchHash: 'depends-on-native@1.0.0' as PkgIdWithPatchHash,
|
|
resolution: { integrity: '003' },
|
|
},
|
|
} as Record<DepPath, { children: Record<string, DepPath>, pkgIdWithPatchHash: PkgIdWithPatchHash, resolution: { integrity: string } }>
|
|
|
|
test('includes ENGINE_NAME when builtDepPaths is not provided', () => {
|
|
const hash = calcGraphNodeHash(
|
|
{ graph: graphNodeGraph, cache: {} },
|
|
{ depPath: 'foo@1.0.0' as DepPath, name: 'foo', version: '1.0.0' }
|
|
)
|
|
expect(hash).toContain('foo/1.0.0/')
|
|
// Hash should include ENGINE_NAME (default behavior)
|
|
const depsHash = hashObject({
|
|
id: 'foo@1.0.0:000',
|
|
deps: {
|
|
bar: hashObject({ id: 'bar@1.0.0:001', deps: {} }),
|
|
},
|
|
})
|
|
const expectedDigest = hashObjectWithoutSorting(
|
|
{ engine: ENGINE_NAME, deps: depsHash },
|
|
{ encoding: 'hex' }
|
|
)
|
|
expect(hash).toBe(`@/foo/1.0.0/${expectedDigest}`)
|
|
})
|
|
|
|
test('omits ENGINE_NAME for pure-JS packages when builtDepPaths is provided', () => {
|
|
const builtDepPaths = new Set<DepPath>(['native@1.0.0' as DepPath])
|
|
const hash = calcGraphNodeHash(
|
|
{ graph: graphNodeGraph, cache: {}, builtDepPaths, buildRequiredCache: {} },
|
|
{ depPath: 'foo@1.0.0' as DepPath, name: 'foo', version: '1.0.0' }
|
|
)
|
|
const depsHash = hashObject({
|
|
id: 'foo@1.0.0:000',
|
|
deps: {
|
|
bar: hashObject({ id: 'bar@1.0.0:001', deps: {} }),
|
|
},
|
|
})
|
|
const expectedDigest = hashObjectWithoutSorting(
|
|
{ engine: null, deps: depsHash },
|
|
{ encoding: 'hex' }
|
|
)
|
|
expect(hash).toBe(`@/foo/1.0.0/${expectedDigest}`)
|
|
})
|
|
|
|
test('includes ENGINE_NAME for packages that require a build', () => {
|
|
const builtDepPaths = new Set<DepPath>(['native@1.0.0' as DepPath])
|
|
const hash = calcGraphNodeHash(
|
|
{ graph: graphNodeGraph, cache: {}, builtDepPaths, buildRequiredCache: {} },
|
|
{ depPath: 'native@1.0.0' as DepPath, name: 'native', version: '1.0.0' }
|
|
)
|
|
const depsHash = hashObject({ id: 'native@1.0.0:002', deps: {} })
|
|
const expectedDigest = hashObjectWithoutSorting(
|
|
{ engine: ENGINE_NAME, deps: depsHash },
|
|
{ encoding: 'hex' }
|
|
)
|
|
expect(hash).toBe(`@/native/1.0.0/${expectedDigest}`)
|
|
})
|
|
|
|
test('includes ENGINE_NAME for packages that transitively depend on a built package', () => {
|
|
const builtDepPaths = new Set<DepPath>(['native@1.0.0' as DepPath])
|
|
const hash = calcGraphNodeHash(
|
|
{ graph: graphNodeGraph, cache: {}, builtDepPaths, buildRequiredCache: {} },
|
|
{ depPath: 'depends-on-native@1.0.0' as DepPath, name: 'depends-on-native', version: '1.0.0' }
|
|
)
|
|
const depsHash = hashObject({
|
|
id: 'depends-on-native@1.0.0:003',
|
|
deps: {
|
|
native: hashObject({ id: 'native@1.0.0:002', deps: {} }),
|
|
},
|
|
})
|
|
const expectedDigest = hashObjectWithoutSorting(
|
|
{ engine: ENGINE_NAME, deps: depsHash },
|
|
{ encoding: 'hex' }
|
|
)
|
|
expect(hash).toBe(`@/depends-on-native/1.0.0/${expectedDigest}`)
|
|
})
|
|
|
|
test('omits ENGINE_NAME when builtDepPaths is empty', () => {
|
|
const builtDepPaths = new Set<DepPath>()
|
|
const hash = calcGraphNodeHash(
|
|
{ graph: graphNodeGraph, cache: {}, builtDepPaths, buildRequiredCache: {} },
|
|
{ depPath: 'foo@1.0.0' as DepPath, name: 'foo', version: '1.0.0' }
|
|
)
|
|
const depsHash = hashObject({
|
|
id: 'foo@1.0.0:000',
|
|
deps: {
|
|
bar: hashObject({ id: 'bar@1.0.0:001', deps: {} }),
|
|
},
|
|
})
|
|
const expectedDigest = hashObjectWithoutSorting(
|
|
{ engine: null, deps: depsHash },
|
|
{ encoding: 'hex' }
|
|
)
|
|
expect(hash).toBe(`@/foo/1.0.0/${expectedDigest}`)
|
|
})
|
|
})
|