Files
pnpm/installing/commands/test/updateWorkspaceDependencies.test.ts
Zoltan Kochan 7a304b17c4 refactor: rename directories and unify command packages per domain (#10993)
- Rename `installing/core` → `installing/deps-installer` and `installing/headless` → `installing/deps-restorer` for clearer naming
- Rename all `plugin-commands-*` directories to use `-commands` suffix convention
- Merge multiple command packages per domain into a single `commands/` directory (one commands package per domain rule):
  - `building/{build-commands,policy-commands}` → `building/commands`
  - `deps/compliance/{audit-commands,licenses-commands,sbom-commands}` → `deps/compliance/commands`
  - `deps/inspection/{listing-commands,outdated-commands}` → `deps/inspection/commands`
  - `store/{store-commands,inspecting-commands}` → `store/commands`
  - `releasing/{publish-commands,deploy-commands}` → `releasing/commands`
  - `cli/{completion-commands,doctor-commands}` → `cli/commands`
  - `engine/pm/{self-updater-commands,setup-commands}` → `engine/pm/commands`
  - `engine/runtime/{runtime-commands,env-commands}` → `engine/runtime/commands`
  - `cache/cache-commands` → `cache/commands`
- Fix relative paths in merged test files (pnpmBin, __typings__ references)
- Update jest config to ignore `utils/` dirs at any nesting depth under `test/`
- Fix stale package names in changeset files
2026-03-17 17:42:20 +01:00

87 lines
2.0 KiB
TypeScript

import type { PnpmError } from '@pnpm/error'
import type { ProjectRootDir } from '@pnpm/types'
import {
createWorkspaceSpecs,
updateToWorkspacePackagesFromManifest,
} from '../lib/updateWorkspaceDependencies.js'
const INCLUDE_ALL = {
dependencies: true,
devDependencies: true,
optionalDependencies: true,
}
const WORKSPACE_PACKAGES = new Map([
['bar', new Map([
['100.0.0', {
rootDir: '' as ProjectRootDir,
manifest: {
name: 'foo',
version: '100.0.0',
},
}],
])],
['foo', new Map([
['100.0.0', {
rootDir: '' as ProjectRootDir,
manifest: {
name: 'foo',
version: '100.0.0',
},
}],
])],
['qar', new Map([
['100.0.0', {
rootDir: '' as ProjectRootDir,
manifest: {
name: 'foo',
version: '100.0.0',
},
}],
])],
])
test('updateToWorkspacePackagesFromManifest()', () => {
const manifest = {
dependencies: {
alpha: '1.0.0',
foo: '1.0.0',
},
devDependencies: {
bar: '1.0.0',
betta: '1.0.0',
},
optionalDependencies: {
hamma: '1.0.0', // cspell:disable-line
qar: '1.0.0',
},
}
expect(updateToWorkspacePackagesFromManifest(
manifest,
INCLUDE_ALL,
WORKSPACE_PACKAGES
)).toStrictEqual(['bar@workspace:*', 'foo@workspace:*', 'qar@workspace:*'])
expect(updateToWorkspacePackagesFromManifest(
manifest,
{
dependencies: true,
devDependencies: false,
optionalDependencies: false,
},
WORKSPACE_PACKAGES
)).toStrictEqual(['foo@workspace:*'])
})
test('createWorkspaceSpecs', () => {
expect(createWorkspaceSpecs(['bar', 'foo@2', 'qar@workspace:3'], WORKSPACE_PACKAGES)).toStrictEqual(['bar@workspace:*', 'foo@workspace:2', 'qar@workspace:3'])
let err!: PnpmError
try {
createWorkspaceSpecs(['express'], WORKSPACE_PACKAGES)
} catch (_err: any) { // eslint-disable-line
err = _err
}
expect(err.code).toBe('ERR_PNPM_WORKSPACE_PACKAGE_NOT_FOUND')
expect(err.message).toBe('"express" not found in the workspace')
})