mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-23 23:29:17 -05:00
feat!: remove conversion of lockfile v6 to v9 (#8866)
This commit is contained in:
39
.changeset/swift-trainers-unite.md
Normal file
39
.changeset/swift-trainers-unite.md
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-installation": major
|
||||
"@pnpm/resolve-dependencies": major
|
||||
"@pnpm/reviewing.dependencies-hierarchy": major
|
||||
"@pnpm/plugin-commands-audit": major
|
||||
"@pnpm/plugin-commands-rebuild": major
|
||||
"@pnpm/modules-cleaner": major
|
||||
"@pnpm/lockfile.detect-dep-types": major
|
||||
"@pnpm/lockfile.settings-checker": major
|
||||
"@pnpm/license-scanner": major
|
||||
"@pnpm/assert-project": major
|
||||
"@pnpm/lockfile-to-pnp": major
|
||||
"@pnpm/calc-dep-state": major
|
||||
"@pnpm/get-context": major
|
||||
"@pnpm/mount-modules": major
|
||||
"@pnpm/real-hoist": major
|
||||
"@pnpm/lockfile.verification": major
|
||||
"@pnpm/headless": major
|
||||
"@pnpm/deps.graph-builder": major
|
||||
"@pnpm/lockfile.filtering": major
|
||||
"@pnpm/outdated": major
|
||||
"@pnpm/hoist": major
|
||||
"@pnpm/core": major
|
||||
"@pnpm/lockfile.merger": major
|
||||
"@pnpm/lockfile.pruner": major
|
||||
"@pnpm/lockfile.walker": major
|
||||
"@pnpm/pnpmfile": major
|
||||
"@pnpm/audit": major
|
||||
"@pnpm/lockfile.types": major
|
||||
"@pnpm/lockfile.utils": major
|
||||
"@pnpm-private/updater": major
|
||||
"@pnpm/dedupe.check": major
|
||||
"@pnpm/deps.status": major
|
||||
"@pnpm/hooks.types": major
|
||||
"@pnpm/lockfile.fs": major
|
||||
"pnpm": major
|
||||
---
|
||||
|
||||
Removed lockfile conversion from v6 to v9. If you need to convert lockfile v6 to v9, use pnpm CLI v9.
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { readWantedLockfile, type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { readWantedLockfile, type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import { type ProjectId, type ProjectManifest } from '@pnpm/types'
|
||||
import { createUpdateOptions, type FormatPluginFnOptions } from '@pnpm/meta-updater'
|
||||
import { parsePkgAndParentSelector } from '@pnpm/parse-overrides'
|
||||
@@ -116,7 +116,7 @@ export default async (workspaceDir: string) => { // eslint-disable-line
|
||||
|
||||
async function updateTSConfig (
|
||||
context: {
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
workspaceDir: string
|
||||
},
|
||||
tsConfig: object | null,
|
||||
|
||||
147
__fixtures__/fixtureWithLinks/general/pnpm-lock.yaml
generated
147
__fixtures__/fixtureWithLinks/general/pnpm-lock.yaml
generated
@@ -1,96 +1,119 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
dependencies:
|
||||
minimatch:
|
||||
specifier: ^3.0.4
|
||||
version: 3.0.4
|
||||
rimraf:
|
||||
specifier: 2.5.1
|
||||
version: 2.5.1
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
optionalDependencies:
|
||||
is-negative:
|
||||
specifier: 1.0.0
|
||||
version: 1.0.0
|
||||
importers:
|
||||
|
||||
devDependencies:
|
||||
is-positive:
|
||||
specifier: 1.0.0
|
||||
version: 1.0.0
|
||||
.:
|
||||
dependencies:
|
||||
minimatch:
|
||||
specifier: ^3.0.4
|
||||
version: 3.1.2
|
||||
rimraf:
|
||||
specifier: 2.5.1
|
||||
version: 2.5.1
|
||||
optionalDependencies:
|
||||
is-negative:
|
||||
specifier: 1.0.0
|
||||
version: 1.0.0
|
||||
devDependencies:
|
||||
is-positive:
|
||||
specifier: 1.0.0
|
||||
version: 1.0.0
|
||||
|
||||
packages:
|
||||
|
||||
/balanced-match@1.0.0:
|
||||
resolution: {integrity: sha512-9Y0g0Q8rmSt+H33DfKv7FOc3v+iRI+o1lbzt8jGcIosYW37IIW/2XVYq5NPdmaD5NQ59Nk26Kl/vZbwW9Fr8vg==}
|
||||
dev: false
|
||||
balanced-match@1.0.2:
|
||||
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
||||
|
||||
/brace-expansion@1.1.11:
|
||||
brace-expansion@1.1.11:
|
||||
resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==}
|
||||
dependencies:
|
||||
balanced-match: 1.0.0
|
||||
concat-map: 0.0.1
|
||||
dev: false
|
||||
|
||||
/concat-map@0.0.1:
|
||||
concat-map@0.0.1:
|
||||
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
|
||||
dev: false
|
||||
|
||||
/glob@6.0.4:
|
||||
glob@6.0.4:
|
||||
resolution: {integrity: sha512-MKZeRNyYZAVVVG1oZeLaWie1uweH40m9AZwIwxyPbTSX4hHrVYSzLg0Ro5Z5R7XKkIX+Cc6oD1rqeDJnwsB8/A==}
|
||||
dependencies:
|
||||
inflight: 1.0.6
|
||||
inherits: 2.0.3
|
||||
minimatch: 3.0.4
|
||||
once: 1.4.0
|
||||
path-is-absolute: 1.0.1
|
||||
dev: false
|
||||
deprecated: Glob versions prior to v9 are no longer supported
|
||||
|
||||
/inflight@1.0.6:
|
||||
inflight@1.0.6:
|
||||
resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==}
|
||||
dependencies:
|
||||
once: 1.4.0
|
||||
wrappy: 1.0.2
|
||||
dev: false
|
||||
deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
|
||||
|
||||
/inherits@2.0.3:
|
||||
resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==}
|
||||
dev: false
|
||||
inherits@2.0.4:
|
||||
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
|
||||
|
||||
/is-negative@1.0.0:
|
||||
is-negative@1.0.0:
|
||||
resolution: {integrity: sha512-1aKMsFUc7vYQGzt//8zhkjRWPoYkajY/I5MJEvrc0pDoHXrW7n5ri8DYxhy3rR+Dk0QFl7GjHHsZU1sppQrWtw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/is-positive@1.0.0:
|
||||
is-positive@1.0.0:
|
||||
resolution: {integrity: sha512-xxzPGZ4P2uN6rROUa5N9Z7zTX6ERuE0hs6GUOc/cKBLF2NqKc16UwqHMt3tFg4CO6EBTE5UecUasg+3jZx3Ckg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: true
|
||||
|
||||
/minimatch@3.0.4:
|
||||
resolution: {integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==}
|
||||
dependencies:
|
||||
brace-expansion: 1.1.11
|
||||
dev: false
|
||||
minimatch@3.1.2:
|
||||
resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
|
||||
|
||||
/once@1.4.0:
|
||||
once@1.4.0:
|
||||
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
|
||||
dependencies:
|
||||
wrappy: 1.0.2
|
||||
dev: false
|
||||
|
||||
/path-is-absolute@1.0.1:
|
||||
path-is-absolute@1.0.1:
|
||||
resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: false
|
||||
|
||||
/rimraf@2.5.1:
|
||||
rimraf@2.5.1:
|
||||
resolution: {integrity: sha512-CNymZDrSR9PfkqZnBWaIki7Wlba4c7GzSkSKsHHvjXswXmJA1hM8ZHFrNWIt4L/WcR9kOwvsJZpbxV4fygtXag==}
|
||||
deprecated: Rimraf versions prior to v4 are no longer supported
|
||||
hasBin: true
|
||||
|
||||
wrappy@1.0.2:
|
||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
||||
|
||||
snapshots:
|
||||
|
||||
balanced-match@1.0.2: {}
|
||||
|
||||
brace-expansion@1.1.11:
|
||||
dependencies:
|
||||
balanced-match: 1.0.2
|
||||
concat-map: 0.0.1
|
||||
|
||||
concat-map@0.0.1: {}
|
||||
|
||||
glob@6.0.4:
|
||||
dependencies:
|
||||
inflight: 1.0.6
|
||||
inherits: 2.0.4
|
||||
minimatch: 3.1.2
|
||||
once: 1.4.0
|
||||
path-is-absolute: 1.0.1
|
||||
|
||||
inflight@1.0.6:
|
||||
dependencies:
|
||||
once: 1.4.0
|
||||
wrappy: 1.0.2
|
||||
|
||||
inherits@2.0.4: {}
|
||||
|
||||
is-negative@1.0.0:
|
||||
optional: true
|
||||
|
||||
is-positive@1.0.0: {}
|
||||
|
||||
minimatch@3.1.2:
|
||||
dependencies:
|
||||
brace-expansion: 1.1.11
|
||||
|
||||
once@1.4.0:
|
||||
dependencies:
|
||||
wrappy: 1.0.2
|
||||
|
||||
path-is-absolute@1.0.1: {}
|
||||
|
||||
rimraf@2.5.1:
|
||||
dependencies:
|
||||
glob: 6.0.4
|
||||
dev: false
|
||||
|
||||
/wrappy@1.0.2:
|
||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
||||
dev: false
|
||||
wrappy@1.0.2: {}
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
dependencies:
|
||||
general:
|
||||
specifier: 0.0.0
|
||||
version: link:../general
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
general:
|
||||
specifier: 0.0.0
|
||||
version: link:../general
|
||||
|
||||
20
__fixtures__/has-major-outdated-deps/node_modules/.pnpm/lock.yaml
generated
vendored
20
__fixtures__/has-major-outdated-deps/node_modules/.pnpm/lock.yaml
generated
vendored
@@ -1,14 +1,16 @@
|
||||
lockfileVersion: '6.1'
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
dependencies:
|
||||
is-negative:
|
||||
version: 1.0.0
|
||||
specifier: 1.0.0
|
||||
importers:
|
||||
'.':
|
||||
dependencies:
|
||||
is-negative:
|
||||
version: 1.0.0
|
||||
specifier: 1.0.0
|
||||
|
||||
devDependencies:
|
||||
is-positive:
|
||||
version: 2.0.0
|
||||
specifier: 2.0.0
|
||||
devDependencies:
|
||||
is-positive:
|
||||
version: 2.0.0
|
||||
specifier: 2.0.0
|
||||
|
||||
packages:
|
||||
|
||||
|
||||
18
__fixtures__/has-major-outdated-deps/pnpm-lock.yaml
generated
18
__fixtures__/has-major-outdated-deps/pnpm-lock.yaml
generated
@@ -1,14 +1,16 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
dependencies:
|
||||
is-negative:
|
||||
version: 1.0.0
|
||||
specifier: 1.0.0
|
||||
importers:
|
||||
'.':
|
||||
dependencies:
|
||||
is-negative:
|
||||
version: 1.0.0
|
||||
specifier: 1.0.0
|
||||
|
||||
devDependencies:
|
||||
is-positive:
|
||||
version: 2.0.0
|
||||
specifier: 2.0.0
|
||||
devDependencies:
|
||||
is-positive:
|
||||
version: 2.0.0
|
||||
specifier: 2.0.0
|
||||
|
||||
packages:
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import path from 'path'
|
||||
import util from 'util'
|
||||
import { assertStore } from '@pnpm/assert-store'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { type LockfileFileV9 } from '@pnpm/lockfile.types'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { type Modules } from '@pnpm/modules-yaml'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { sync as readYamlFile } from 'read-yaml-file'
|
||||
@@ -31,14 +31,14 @@ export interface Project {
|
||||
*
|
||||
* https://github.com/microsoft/TypeScript/pull/32695 might help with this.
|
||||
*/
|
||||
readCurrentLockfile: () => Required<LockfileFileV9>
|
||||
readCurrentLockfile: () => Required<LockfileFile>
|
||||
readModulesManifest: () => Modules | null
|
||||
/**
|
||||
* TODO: Remove the `Required<T>` cast.
|
||||
*
|
||||
* https://github.com/microsoft/TypeScript/pull/32695 might help with this.
|
||||
*/
|
||||
readLockfile: (lockfileName?: string) => Required<LockfileFileV9>
|
||||
readLockfile: (lockfileName?: string) => Required<LockfileFile>
|
||||
writePackageJson: (pkgJson: object) => void
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type ResolvedDependencies, type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type ResolvedDependencies, type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import {
|
||||
type ResolutionChangesByAlias,
|
||||
type DedupeCheckIssues,
|
||||
@@ -9,7 +9,7 @@ import { DedupeCheckIssuesError } from './DedupeCheckIssuesError'
|
||||
|
||||
const PACKAGE_SNAPSHOT_DEP_FIELDS = ['dependencies', 'optionalDependencies'] as const
|
||||
|
||||
export function dedupeDiffCheck (prev: Lockfile, next: Lockfile): void {
|
||||
export function dedupeDiffCheck (prev: LockfileObject, next: LockfileObject): void {
|
||||
const issues: DedupeCheckIssues = {
|
||||
importerIssuesByImporterId: diffSnapshots(prev.importers, next.importers, DEPENDENCIES_FIELDS),
|
||||
packageIssuesByDepPath: diffSnapshots(prev.packages ?? {}, next.packages ?? {}, PACKAGE_SNAPSHOT_DEP_FIELDS),
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { DedupeCheckIssuesError, dedupeDiffCheck } from '@pnpm/dedupe.check'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { type DepPath, type ProjectId } from '@pnpm/types'
|
||||
|
||||
describe('dedupeDiffCheck', () => {
|
||||
it('should have no changes for same lockfile', () => {
|
||||
const lockfile: Lockfile = {
|
||||
const lockfile: LockfileObject = {
|
||||
importers: {
|
||||
['.' as ProjectId]: {
|
||||
specifiers: {},
|
||||
@@ -19,7 +19,7 @@ describe('dedupeDiffCheck', () => {
|
||||
})
|
||||
|
||||
it('throws DedupeCheckIssuesError on changes', () => {
|
||||
const before: Lockfile = {
|
||||
const before: LockfileObject = {
|
||||
importers: {
|
||||
['packages/a' as ProjectId]: {
|
||||
specifiers: {
|
||||
@@ -59,7 +59,7 @@ describe('dedupeDiffCheck', () => {
|
||||
lockfileVersion: 'testLockfileVersion',
|
||||
}
|
||||
|
||||
const after: Lockfile = {
|
||||
const after: LockfileObject = {
|
||||
importers: {
|
||||
['packages/a' as ProjectId]: {
|
||||
specifiers: {
|
||||
|
||||
6
deps/graph-builder/src/lockfileToDepGraph.ts
vendored
6
deps/graph-builder/src/lockfileToDepGraph.ts
vendored
@@ -4,7 +4,7 @@ import {
|
||||
progressLogger,
|
||||
} from '@pnpm/core-loggers'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type PackageSnapshot,
|
||||
} from '@pnpm/lockfile.fs'
|
||||
import {
|
||||
@@ -93,8 +93,8 @@ export interface LockfileToDepGraphResult {
|
||||
}
|
||||
|
||||
export async function lockfileToDepGraph (
|
||||
lockfile: Lockfile,
|
||||
currentLockfile: Lockfile | null,
|
||||
lockfile: LockfileObject,
|
||||
currentLockfile: LockfileObject | null,
|
||||
opts: LockfileToDepGraphOptions
|
||||
): Promise<LockfileToDepGraphResult> {
|
||||
const currentPackages = currentLockfile?.packages ?? {}
|
||||
|
||||
4
deps/status/src/assertLockfilesEqual.ts
vendored
4
deps/status/src/assertLockfilesEqual.ts
vendored
@@ -1,8 +1,8 @@
|
||||
import { PnpmError } from '@pnpm/error'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import { equals } from 'ramda'
|
||||
|
||||
export function assertLockfilesEqual (currentLockfile: Lockfile | null, wantedLockfile: Lockfile, wantedLockfileDir: string): void {
|
||||
export function assertLockfilesEqual (currentLockfile: LockfileObject | null, wantedLockfile: LockfileObject, wantedLockfileDir: string): void {
|
||||
if (!currentLockfile) {
|
||||
// make sure that no importer of wantedLockfile has any dependency
|
||||
for (const [name, snapshot] of Object.entries(wantedLockfile.importers)) {
|
||||
|
||||
6
deps/status/src/checkDepsStatus.ts
vendored
6
deps/status/src/checkDepsStatus.ts
vendored
@@ -11,7 +11,7 @@ import { hashObjectNullableWithPrefix } from '@pnpm/crypto.object-hasher'
|
||||
import { PnpmError } from '@pnpm/error'
|
||||
import { arrayOfWorkspacePackagesToMap } from '@pnpm/get-context'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
getLockfileImporterId,
|
||||
readCurrentLockfile,
|
||||
readWantedLockfile,
|
||||
@@ -182,7 +182,7 @@ async function _checkDepsStatus (opts: CheckDepsStatusOptions): Promise<{ upToDa
|
||||
logger.debug({ msg: 'Some manifest files were modified since the last validation. Continuing check.' })
|
||||
|
||||
let readWantedLockfileAndDir: (projectDir: string) => Promise<{
|
||||
wantedLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
wantedLockfileDir: string
|
||||
}>
|
||||
if (sharedWorkspaceLockfile) {
|
||||
@@ -391,7 +391,7 @@ interface AssertWantedLockfileUpToDateOptions {
|
||||
projectDir: string
|
||||
projectId: ProjectId
|
||||
projectManifest: ProjectManifest
|
||||
wantedLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
wantedLockfileDir: string
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { LOCKFILE_VERSION } from '@pnpm/constants'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import { type ProjectId } from '@pnpm/types'
|
||||
import { assertLockfilesEqual } from '../src/assertLockfilesEqual'
|
||||
|
||||
@@ -32,7 +32,7 @@ test('should throw if wantedLockfile has specifiers but currentLockfile is null'
|
||||
})
|
||||
|
||||
test('should not throw if wantedLockfile and currentLockfile are equal', () => {
|
||||
const lockfile = (): Lockfile => ({
|
||||
const lockfile = (): LockfileObject => ({
|
||||
lockfileVersion: LOCKFILE_VERSION,
|
||||
importers: {
|
||||
['.' as ProjectId]: {
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
import { linkBins } from '@pnpm/link-bins'
|
||||
import { type TarballResolution } from '@pnpm/lockfile.types'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
nameVerFromPkgSnapshot,
|
||||
packageIsIndependent,
|
||||
type PackageSnapshots,
|
||||
@@ -240,7 +240,7 @@ async function _rebuild (
|
||||
skipped: Set<string>
|
||||
virtualStoreDir: string
|
||||
rootModulesDir: string
|
||||
currentLockfile: Lockfile
|
||||
currentLockfile: LockfileObject
|
||||
projects: Record<string, { id: ProjectId, rootDir: ProjectRootDir }>
|
||||
extraBinPaths: string[]
|
||||
extraNodePaths: string[]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { PreResolutionHook } from '@pnpm/hooks.types'
|
||||
import type { Lockfile } from '@pnpm/lockfile.types'
|
||||
import type { Log } from '@pnpm/core-loggers'
|
||||
import type { CustomFetchers } from '@pnpm/fetcher-base'
|
||||
import { type PreResolutionHook } from '@pnpm/hooks.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { type Log } from '@pnpm/core-loggers'
|
||||
import { type CustomFetchers } from '@pnpm/fetcher-base'
|
||||
import { type ImportIndexedPackageAsync } from '@pnpm/store-controller-types'
|
||||
|
||||
export interface HookContext {
|
||||
@@ -12,7 +12,7 @@ export interface Hooks {
|
||||
// eslint-disable-next-line
|
||||
readPackage?: (pkg: any, context: HookContext) => any;
|
||||
preResolution?: PreResolutionHook
|
||||
afterAllResolved?: (lockfile: Lockfile, context: HookContext) => Lockfile | Promise<Lockfile>
|
||||
afterAllResolved?: (lockfile: LockfileObject, context: HookContext) => LockfileObject | Promise<LockfileObject>
|
||||
filterLog?: (log: Log) => boolean
|
||||
importPackage?: ImportIndexedPackageAsync
|
||||
fetchers?: CustomFetchers
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { Lockfile } from '@pnpm/lockfile.types'
|
||||
import type { Registries } from '@pnpm/types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { type Registries } from '@pnpm/types'
|
||||
|
||||
export interface PreResolutionHookContext {
|
||||
wantedLockfile: Lockfile
|
||||
currentLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
currentLockfile: LockfileObject
|
||||
existsCurrentLockfile: boolean
|
||||
existsNonEmptyWantedLockfile: boolean
|
||||
lockfileDir: string
|
||||
|
||||
@@ -4,7 +4,7 @@ import util from 'util'
|
||||
import { PnpmError } from '@pnpm/error'
|
||||
import { type AgentOptions, fetchWithAgent, type RetryTimeoutOptions } from '@pnpm/fetch'
|
||||
import { type GetAuthHeader } from '@pnpm/fetching-types'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { globalWarn } from '@pnpm/logger'
|
||||
import { type DependenciesField } from '@pnpm/types'
|
||||
import { lockfileToAuditTree } from './lockfileToAuditTree'
|
||||
@@ -14,7 +14,7 @@ import { searchForPackages, flattenSearchedPackages } from '@pnpm/list'
|
||||
export * from './types'
|
||||
|
||||
export async function audit (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
getAuthHeader: GetAuthHeader,
|
||||
opts: {
|
||||
agentOptions?: AgentOptions
|
||||
@@ -78,7 +78,7 @@ function getAuthHeaders (authHeaderValue: string | undefined): AuthHeaders {
|
||||
}
|
||||
|
||||
async function extendWithDependencyPaths (auditReport: AuditReport, opts: {
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
lockfileDir: string
|
||||
include?: { [dependenciesField in DependenciesField]: boolean }
|
||||
virtualStoreDirMaxLength: number
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from 'path'
|
||||
import { type Lockfile, type TarballResolution } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject, type TarballResolution } from '@pnpm/lockfile.types'
|
||||
import { nameVerFromPkgSnapshot } from '@pnpm/lockfile.utils'
|
||||
import { lockfileWalkerGroupImporterSteps, type LockfileWalkerStep } from '@pnpm/lockfile.walker'
|
||||
import { detectDepTypes, type DepTypes, DepType } from '@pnpm/lockfile.detect-dep-types'
|
||||
@@ -23,7 +23,7 @@ export type AuditTree = AuditNode & {
|
||||
}
|
||||
|
||||
export async function lockfileToAuditTree (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
opts: {
|
||||
include?: { [dependenciesField in DependenciesField]: boolean }
|
||||
lockfileDir: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Lockfile, type PackageSnapshots, type ResolvedDependencies } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject, type PackageSnapshots, type ResolvedDependencies } from '@pnpm/lockfile.types'
|
||||
import * as dp from '@pnpm/dependency-path'
|
||||
import { type DepPath } from '@pnpm/types'
|
||||
|
||||
@@ -10,7 +10,7 @@ export enum DepType {
|
||||
|
||||
export type DepTypes = Record<string, DepType>
|
||||
|
||||
export function detectDepTypes (lockfile: Lockfile): DepTypes {
|
||||
export function detectDepTypes (lockfile: LockfileObject): DepTypes {
|
||||
const dev: DepTypes = {}
|
||||
const devDepPaths = Object.values(lockfile.importers)
|
||||
.map((deps) => resolvedDepsToDepPaths(deps.devDependencies ?? {})).flat()
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { type DependenciesField, type DepPath, type ProjectId } from '@pnpm/types'
|
||||
import { filterLockfileByImporters } from './filterLockfileByImporters'
|
||||
|
||||
export function filterLockfile (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
opts: {
|
||||
include: { [dependenciesField in DependenciesField]: boolean }
|
||||
skipped: Set<DepPath>
|
||||
}
|
||||
): Lockfile {
|
||||
): LockfileObject {
|
||||
return filterLockfileByImporters(lockfile, Object.keys(lockfile.importers) as ProjectId[], {
|
||||
...opts,
|
||||
failOnMissingDependencies: false,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { LockfileMissingDependencyError } from '@pnpm/error'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type PackageSnapshots,
|
||||
} from '@pnpm/lockfile.types'
|
||||
import { lockfileWalker, type LockfileWalkerStep } from '@pnpm/lockfile.walker'
|
||||
@@ -12,14 +12,14 @@ import { filterImporter } from './filterImporter'
|
||||
const lockfileLogger = logger('lockfile')
|
||||
|
||||
export function filterLockfileByImporters (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
importerIds: ProjectId[],
|
||||
opts: {
|
||||
include: { [dependenciesField in DependenciesField]: boolean }
|
||||
skipped: Set<DepPath>
|
||||
failOnMissingDependencies: boolean
|
||||
}
|
||||
): Lockfile {
|
||||
): LockfileObject {
|
||||
const packages = {} as PackageSnapshots
|
||||
if (lockfile.packages != null) {
|
||||
pkgAllDeps(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { LockfileMissingDependencyError } from '@pnpm/error'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type PackageSnapshots,
|
||||
} from '@pnpm/lockfile.types'
|
||||
import { nameVerFromPkgSnapshot } from '@pnpm/lockfile.utils'
|
||||
@@ -17,12 +17,12 @@ import { filterImporter } from './filterImporter'
|
||||
const lockfileLogger = logger('lockfile')
|
||||
|
||||
export interface FilterLockfileResult {
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
selectedImporterIds: ProjectId[]
|
||||
}
|
||||
|
||||
export function filterLockfileByEngine (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
opts: FilterLockfileOptions
|
||||
): FilterLockfileResult {
|
||||
const importerIds = Object.keys(lockfile.importers) as ProjectId[]
|
||||
@@ -44,7 +44,7 @@ export interface FilterLockfileOptions {
|
||||
}
|
||||
|
||||
export function filterLockfileByImportersAndEngine (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
importerIds: ProjectId[],
|
||||
opts: FilterLockfileOptions
|
||||
): FilterLockfileResult {
|
||||
@@ -92,7 +92,7 @@ export function filterLockfileByImportersAndEngine (
|
||||
}
|
||||
|
||||
function pickPkgsWithAllDeps (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
depPaths: DepPath[],
|
||||
importerIdSet: Set<ProjectId>,
|
||||
opts: {
|
||||
@@ -116,7 +116,7 @@ function pickPkgsWithAllDeps (
|
||||
|
||||
function pkgAllDeps (
|
||||
ctx: {
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
pickedPackages: PackageSnapshots
|
||||
importerIdSet: Set<ProjectId>
|
||||
},
|
||||
@@ -197,7 +197,7 @@ function pkgAllDeps (
|
||||
}
|
||||
|
||||
function toImporterDepPaths (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
importerIds: ProjectId[],
|
||||
opts: {
|
||||
include: { [dependenciesField in DependenciesField]: boolean }
|
||||
@@ -235,7 +235,7 @@ interface ParsedDepRefs {
|
||||
importerIds: ProjectId[]
|
||||
}
|
||||
|
||||
function parseDepRefs (refsByPkgNames: Array<[string, string]>, lockfile: Lockfile): ParsedDepRefs {
|
||||
function parseDepRefs (refsByPkgNames: Array<[string, string]>, lockfile: LockfileObject): ParsedDepRefs {
|
||||
const acc: ParsedDepRefs = {
|
||||
depPaths: [],
|
||||
importerIds: [],
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"@pnpm/constants": "workspace:*",
|
||||
"@pnpm/dependency-path": "workspace:*",
|
||||
"@pnpm/error": "workspace:*",
|
||||
"@pnpm/git-resolver": "workspace:*",
|
||||
"@pnpm/git-utils": "workspace:*",
|
||||
"@pnpm/lockfile.merger": "workspace:*",
|
||||
"@pnpm/lockfile.types": "workspace:*",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Lockfile, type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject, type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { mergeLockfileChanges } from '@pnpm/lockfile.merger'
|
||||
import yaml from 'js-yaml'
|
||||
import { convertToLockfileObject } from './lockfileFormatConverters'
|
||||
@@ -8,7 +8,7 @@ const MERGE_CONFLICT_END = '>>>>>>>'
|
||||
const MERGE_CONFLICT_THEIRS = '======='
|
||||
const MERGE_CONFLICT_OURS = '<<<<<<<'
|
||||
|
||||
export function autofixMergeConflicts (fileContent: string): Lockfile {
|
||||
export function autofixMergeConflicts (fileContent: string): LockfileObject {
|
||||
const { ours, theirs } = parseMergeFile(fileContent)
|
||||
return mergeLockfileChanges(
|
||||
convertToLockfileObject(yaml.load(ours) as LockfileFile),
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
import { parseDepPath, removeSuffix } from '@pnpm/dependency-path'
|
||||
import { createGitHostedPkgId } from '@pnpm/git-resolver'
|
||||
import { removeSuffix } from '@pnpm/dependency-path'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type ProjectSnapshot,
|
||||
type PackageSnapshotV7,
|
||||
type LockfilePackageSnapshot,
|
||||
type ResolvedDependencies,
|
||||
type LockfileFile,
|
||||
type InlineSpecifiersLockfile,
|
||||
type InlineSpecifiersProjectSnapshot,
|
||||
type InlineSpecifiersResolvedDependencies,
|
||||
type PackageInfo,
|
||||
type LockfileFileV9,
|
||||
type LockfilePackageInfo,
|
||||
type PackageSnapshots,
|
||||
} from '@pnpm/lockfile.types'
|
||||
import { type DepPath, DEPENDENCIES_FIELDS } from '@pnpm/types'
|
||||
import equals from 'ramda/src/equals'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import _mapValues from 'ramda/src/map'
|
||||
import omit from 'ramda/src/omit'
|
||||
@@ -22,13 +18,9 @@ import pickBy from 'ramda/src/pickBy'
|
||||
import pick from 'ramda/src/pick'
|
||||
import { LOCKFILE_VERSION } from '@pnpm/constants'
|
||||
|
||||
export interface NormalizeLockfileOpts {
|
||||
forceSharedFormat: boolean
|
||||
}
|
||||
|
||||
export function convertToLockfileFile (lockfile: Lockfile, opts: NormalizeLockfileOpts): LockfileFile {
|
||||
const packages: Record<string, PackageInfo> = {}
|
||||
const snapshots: Record<string, PackageSnapshotV7> = {}
|
||||
export function convertToLockfileFile (lockfile: LockfileObject): LockfileFile {
|
||||
const packages: Record<string, LockfilePackageInfo> = {}
|
||||
const snapshots: Record<string, LockfilePackageSnapshot> = {}
|
||||
for (const [depPath, pkg] of Object.entries(lockfile.packages ?? {})) {
|
||||
snapshots[depPath] = pick([
|
||||
'dependencies',
|
||||
@@ -68,53 +60,33 @@ export function convertToLockfileFile (lockfile: Lockfile, opts: NormalizeLockfi
|
||||
if (newLockfile.settings?.injectWorkspacePackages === false) {
|
||||
delete newLockfile.settings.injectWorkspacePackages
|
||||
}
|
||||
return normalizeLockfile(newLockfile, opts)
|
||||
return normalizeLockfile(newLockfile)
|
||||
}
|
||||
|
||||
function normalizeLockfile (lockfile: InlineSpecifiersLockfile, opts: NormalizeLockfileOpts): LockfileFile {
|
||||
let lockfileToSave!: LockfileFile
|
||||
if (!opts.forceSharedFormat && equals(Object.keys(lockfile.importers ?? {}), ['.'])) {
|
||||
lockfileToSave = {
|
||||
...lockfile,
|
||||
...lockfile.importers?.['.'],
|
||||
}
|
||||
delete lockfileToSave.importers
|
||||
for (const depType of DEPENDENCIES_FIELDS) {
|
||||
if (isEmpty(lockfileToSave[depType])) {
|
||||
delete lockfileToSave[depType]
|
||||
function normalizeLockfile (lockfile: LockfileFile): LockfileFile {
|
||||
const lockfileToSave = {
|
||||
...lockfile,
|
||||
importers: _mapValues((importer) => {
|
||||
const normalizedImporter: Partial<InlineSpecifiersProjectSnapshot> = {}
|
||||
if (importer.dependenciesMeta != null && !isEmpty(importer.dependenciesMeta)) {
|
||||
normalizedImporter.dependenciesMeta = importer.dependenciesMeta
|
||||
}
|
||||
}
|
||||
if (isEmpty(lockfileToSave.packages) || (lockfileToSave.packages == null)) {
|
||||
delete lockfileToSave.packages
|
||||
}
|
||||
if (isEmpty((lockfileToSave as LockfileFileV9).snapshots) || ((lockfileToSave as LockfileFileV9).snapshots == null)) {
|
||||
delete (lockfileToSave as LockfileFileV9).snapshots
|
||||
}
|
||||
} else {
|
||||
lockfileToSave = {
|
||||
...lockfile,
|
||||
importers: _mapValues((importer) => {
|
||||
const normalizedImporter: Partial<InlineSpecifiersProjectSnapshot> = {}
|
||||
if (importer.dependenciesMeta != null && !isEmpty(importer.dependenciesMeta)) {
|
||||
normalizedImporter.dependenciesMeta = importer.dependenciesMeta
|
||||
for (const depType of DEPENDENCIES_FIELDS) {
|
||||
if (!isEmpty(importer[depType] ?? {})) {
|
||||
normalizedImporter[depType] = importer[depType]
|
||||
}
|
||||
for (const depType of DEPENDENCIES_FIELDS) {
|
||||
if (!isEmpty(importer[depType] ?? {})) {
|
||||
normalizedImporter[depType] = importer[depType]
|
||||
}
|
||||
}
|
||||
if (importer.publishDirectory) {
|
||||
normalizedImporter.publishDirectory = importer.publishDirectory
|
||||
}
|
||||
return normalizedImporter as InlineSpecifiersProjectSnapshot
|
||||
}, lockfile.importers ?? {}),
|
||||
}
|
||||
if (isEmpty(lockfileToSave.packages) || (lockfileToSave.packages == null)) {
|
||||
delete lockfileToSave.packages
|
||||
}
|
||||
if (isEmpty((lockfileToSave as LockfileFileV9).snapshots) || ((lockfileToSave as LockfileFileV9).snapshots == null)) {
|
||||
delete (lockfileToSave as LockfileFileV9).snapshots
|
||||
}
|
||||
}
|
||||
if (importer.publishDirectory) {
|
||||
normalizedImporter.publishDirectory = importer.publishDirectory
|
||||
}
|
||||
return normalizedImporter as InlineSpecifiersProjectSnapshot
|
||||
}, lockfile.importers ?? {}),
|
||||
}
|
||||
if (isEmpty(lockfileToSave.packages) || (lockfileToSave.packages == null)) {
|
||||
delete lockfileToSave.packages
|
||||
}
|
||||
if (isEmpty((lockfileToSave as LockfileFile).snapshots) || ((lockfileToSave as LockfileFile).snapshots == null)) {
|
||||
delete (lockfileToSave as LockfileFile).snapshots
|
||||
}
|
||||
if (lockfileToSave.time) {
|
||||
lockfileToSave.time = pruneTimeInLockfileV6(lockfileToSave.time, lockfile.importers ?? {})
|
||||
@@ -172,131 +144,8 @@ function refToRelative (
|
||||
return reference
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverts changes from the "forceSharedFormat" write option if necessary.
|
||||
*/
|
||||
function convertFromLockfileFileMutable (lockfileFile: LockfileFile): LockfileFileV9 {
|
||||
if (typeof lockfileFile?.['importers'] === 'undefined') {
|
||||
lockfileFile.importers = {
|
||||
'.': {
|
||||
dependenciesMeta: lockfileFile['dependenciesMeta'],
|
||||
publishDirectory: lockfileFile['publishDirectory'],
|
||||
},
|
||||
}
|
||||
for (const depType of DEPENDENCIES_FIELDS) {
|
||||
if (lockfileFile[depType] != null) {
|
||||
lockfileFile.importers['.'][depType] = lockfileFile[depType]
|
||||
delete lockfileFile[depType]
|
||||
}
|
||||
}
|
||||
}
|
||||
return lockfileFile as LockfileFileV9
|
||||
}
|
||||
|
||||
export function convertToLockfileObject (lockfile: LockfileFile | LockfileFileV9): Lockfile {
|
||||
if ((lockfile as LockfileFileV9).snapshots) {
|
||||
return convertLockfileV9ToLockfileObject(lockfile as LockfileFileV9)
|
||||
}
|
||||
convertPkgIds(lockfile)
|
||||
const { importers, ...rest } = convertFromLockfileFileMutable(lockfile)
|
||||
|
||||
const newLockfile = {
|
||||
...rest,
|
||||
importers: mapValues(importers ?? {}, revertProjectSnapshot),
|
||||
}
|
||||
return newLockfile
|
||||
}
|
||||
|
||||
function convertPkgIds (lockfile: LockfileFile): void {
|
||||
const oldIdToNewId: Record<string, DepPath> = {}
|
||||
if (lockfile.packages == null || isEmpty(lockfile.packages)) return
|
||||
for (const [pkgId, pkg] of Object.entries(lockfile.packages ?? {})) {
|
||||
if (pkg.name) {
|
||||
const { id, peersSuffix } = parseDepPath(pkgId)
|
||||
let newId = `${pkg.name}@`
|
||||
if ('tarball' in pkg.resolution) {
|
||||
newId += pkg.resolution.tarball
|
||||
if (pkg.resolution.path) {
|
||||
newId += `#path:${pkg.resolution.path}`
|
||||
}
|
||||
} else if ('repo' in pkg.resolution) {
|
||||
newId += createGitHostedPkgId(pkg.resolution)
|
||||
} else if ('directory' in pkg.resolution) {
|
||||
newId += id
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
oldIdToNewId[pkgId] = `${newId}${peersSuffix}` as DepPath
|
||||
if (id !== pkgId) {
|
||||
oldIdToNewId[id] = newId as DepPath
|
||||
}
|
||||
} else {
|
||||
const { id, peersSuffix } = parseDepPath(pkgId)
|
||||
const newId = id.substring(1)
|
||||
oldIdToNewId[pkgId] = `${newId}${peersSuffix}` as DepPath
|
||||
if (id !== pkgId) {
|
||||
oldIdToNewId[id] = newId as DepPath
|
||||
}
|
||||
}
|
||||
}
|
||||
const newLockfilePackages: PackageSnapshots = {}
|
||||
for (const [pkgId, pkg] of Object.entries(lockfile.packages ?? {})) {
|
||||
if (oldIdToNewId[pkgId]) {
|
||||
if (pkg.id) {
|
||||
pkg.id = oldIdToNewId[pkg.id]
|
||||
}
|
||||
newLockfilePackages[oldIdToNewId[pkgId]] = pkg
|
||||
} else {
|
||||
newLockfilePackages[pkgId as DepPath] = pkg
|
||||
}
|
||||
for (const depType of ['dependencies', 'optionalDependencies'] as const) {
|
||||
for (const [alias, depPath] of Object.entries(pkg[depType] ?? {})) {
|
||||
if (oldIdToNewId[depPath as string]) {
|
||||
if (oldIdToNewId[depPath as string].startsWith(`${alias}@`)) {
|
||||
pkg[depType]![alias] = oldIdToNewId[depPath as string].substring(alias.length + 1)
|
||||
} else {
|
||||
pkg[depType]![alias] = oldIdToNewId[depPath as string]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lockfile.packages = newLockfilePackages
|
||||
if ((lockfile.dependencies != null || lockfile.devDependencies != null || lockfile.optionalDependencies != null) && !lockfile.importers?.['.']) {
|
||||
lockfile.importers = lockfile.importers ?? {}
|
||||
lockfile.importers['.'] = {
|
||||
dependencies: lockfile.dependencies,
|
||||
devDependencies: lockfile.devDependencies,
|
||||
optionalDependencies: lockfile.optionalDependencies,
|
||||
}
|
||||
delete lockfile.dependencies
|
||||
delete lockfile.devDependencies
|
||||
delete lockfile.optionalDependencies
|
||||
}
|
||||
for (const importer of Object.values(lockfile.importers ?? {})) {
|
||||
for (const depType of ['dependencies', 'optionalDependencies', 'devDependencies'] as const) {
|
||||
for (const [alias, { version }] of Object.entries(importer[depType] ?? {})) {
|
||||
if (oldIdToNewId[version]) {
|
||||
if (oldIdToNewId[version].startsWith(`${alias}@`)) {
|
||||
importer[depType]![alias].version = oldIdToNewId[version].substring(alias.length + 1)
|
||||
} else {
|
||||
importer[depType]![alias].version = oldIdToNewId[version]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const depType of ['dependencies', 'optionalDependencies', 'devDependencies'] as const) {
|
||||
for (const [alias, { version }] of Object.entries(lockfile[depType] ?? {})) {
|
||||
if (oldIdToNewId[version]) {
|
||||
lockfile[depType]![alias].version = oldIdToNewId[version]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function convertLockfileV9ToLockfileObject (lockfile: LockfileFileV9): Lockfile {
|
||||
const { importers, ...rest } = convertFromLockfileFileMutable(lockfile)
|
||||
export function convertToLockfileObject (lockfile: LockfileFile): LockfileObject {
|
||||
const { importers, ...rest } = lockfile
|
||||
|
||||
const packages: PackageSnapshots = {}
|
||||
for (const [depPath, pkg] of Object.entries(lockfile.snapshots ?? {})) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '@pnpm/constants'
|
||||
import { PnpmError } from '@pnpm/error'
|
||||
import { mergeLockfileChanges } from '@pnpm/lockfile.merger'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { type ProjectId } from '@pnpm/types'
|
||||
import comverToSemver from 'comver-to-semver'
|
||||
import yaml from 'js-yaml'
|
||||
@@ -26,7 +26,7 @@ export async function readCurrentLockfile (
|
||||
wantedVersions?: string[]
|
||||
ignoreIncompatible: boolean
|
||||
}
|
||||
): Promise<Lockfile | null> {
|
||||
): Promise<LockfileObject | null> {
|
||||
const lockfilePath = path.join(virtualStoreDir, 'lock.yaml')
|
||||
return (await _read(lockfilePath, virtualStoreDir, opts)).lockfile
|
||||
}
|
||||
@@ -40,7 +40,7 @@ export async function readWantedLockfileAndAutofixConflicts (
|
||||
mergeGitBranchLockfiles?: boolean
|
||||
}
|
||||
): Promise<{
|
||||
lockfile: Lockfile | null
|
||||
lockfile: LockfileObject | null
|
||||
hadConflicts: boolean
|
||||
}> {
|
||||
return _readWantedLockfile(pkgPath, {
|
||||
@@ -57,7 +57,7 @@ export async function readWantedLockfile (
|
||||
useGitBranchLockfile?: boolean
|
||||
mergeGitBranchLockfiles?: boolean
|
||||
}
|
||||
): Promise<Lockfile | null> {
|
||||
): Promise<LockfileObject | null> {
|
||||
return (await _readWantedLockfile(pkgPath, opts)).lockfile
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ async function _read (
|
||||
ignoreIncompatible: boolean
|
||||
}
|
||||
): Promise<{
|
||||
lockfile: Lockfile | null
|
||||
lockfile: LockfileObject | null
|
||||
hadConflicts: boolean
|
||||
}> {
|
||||
let lockfileRawContent
|
||||
@@ -85,7 +85,7 @@ async function _read (
|
||||
hadConflicts: false,
|
||||
}
|
||||
}
|
||||
let lockfile: Lockfile
|
||||
let lockfile: LockfileObject
|
||||
let hadConflicts!: boolean
|
||||
try {
|
||||
lockfile = convertToLockfileObject(yaml.load(lockfileRawContent) as any) // eslint-disable-line
|
||||
@@ -140,8 +140,8 @@ export function createLockfileObject (
|
||||
excludeLinksFromLockfile: boolean
|
||||
peersSuffixMaxLength: number
|
||||
}
|
||||
): Lockfile {
|
||||
const importers: Lockfile['importers'] = {}
|
||||
): LockfileObject {
|
||||
const importers: LockfileObject['importers'] = {}
|
||||
for (const importerId of importerIds) {
|
||||
importers[importerId] = {
|
||||
dependencies: {},
|
||||
@@ -169,7 +169,7 @@ async function _readWantedLockfile (
|
||||
autofixMergeConflicts?: boolean
|
||||
}
|
||||
): Promise<{
|
||||
lockfile: Lockfile | null
|
||||
lockfile: LockfileObject | null
|
||||
hadConflicts: boolean
|
||||
}> {
|
||||
const lockfileNames: string[] = [WANTED_LOCKFILE]
|
||||
@@ -179,7 +179,7 @@ async function _readWantedLockfile (
|
||||
lockfileNames.unshift(gitBranchLockfileName)
|
||||
}
|
||||
}
|
||||
let result: { lockfile: Lockfile | null, hadConflicts: boolean } = { lockfile: null, hadConflicts: false }
|
||||
let result: { lockfile: LockfileObject | null, hadConflicts: boolean } = { lockfile: null, hadConflicts: false }
|
||||
/* eslint-disable no-await-in-loop */
|
||||
for (const lockfileName of lockfileNames) {
|
||||
result = await _read(path.join(pkgPath, lockfileName), pkgPath, { ...opts, autofixMergeConflicts: true })
|
||||
@@ -195,7 +195,7 @@ async function _readWantedLockfile (
|
||||
}
|
||||
|
||||
async function _mergeGitBranchLockfiles (
|
||||
lockfile: Lockfile | null,
|
||||
lockfile: LockfileObject | null,
|
||||
lockfileDir: string,
|
||||
prefix: string,
|
||||
opts: {
|
||||
@@ -203,13 +203,13 @@ async function _mergeGitBranchLockfiles (
|
||||
wantedVersions?: string[]
|
||||
ignoreIncompatible: boolean
|
||||
}
|
||||
): Promise<Lockfile | null> {
|
||||
): Promise<LockfileObject | null> {
|
||||
if (!lockfile) {
|
||||
return lockfile
|
||||
}
|
||||
const gitBranchLockfiles: Array<(Lockfile | null)> = (await _readGitBranchLockfiles(lockfileDir, prefix, opts)).map(({ lockfile }) => lockfile)
|
||||
const gitBranchLockfiles: Array<(LockfileObject | null)> = (await _readGitBranchLockfiles(lockfileDir, prefix, opts)).map(({ lockfile }) => lockfile)
|
||||
|
||||
let mergedLockfile: Lockfile = lockfile
|
||||
let mergedLockfile: LockfileObject = lockfile
|
||||
|
||||
for (const gitBranchLockfile of gitBranchLockfiles) {
|
||||
if (!gitBranchLockfile) {
|
||||
@@ -230,7 +230,7 @@ async function _readGitBranchLockfiles (
|
||||
ignoreIncompatible: boolean
|
||||
}
|
||||
): Promise<Array<{
|
||||
lockfile: Lockfile | null
|
||||
lockfile: LockfileObject | null
|
||||
hadConflicts: boolean
|
||||
}>> {
|
||||
const files = await getGitBranchLockfileNames(lockfileDir)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { lexCompare } from '@pnpm/util.lex-comparator'
|
||||
import sortKeys from 'sort-keys'
|
||||
import { type LockfileFileV9, type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.types'
|
||||
|
||||
const ORDERED_KEYS = {
|
||||
resolution: 1,
|
||||
@@ -40,10 +40,6 @@ const ROOT_KEYS: readonly RootKey[] = [
|
||||
'packageExtensionsChecksum',
|
||||
'pnpmfileChecksum',
|
||||
'patchedDependencies',
|
||||
'dependencies',
|
||||
'optionalDependencies',
|
||||
'devDependencies',
|
||||
'dependenciesMeta',
|
||||
'importers',
|
||||
'packages',
|
||||
]
|
||||
@@ -58,7 +54,7 @@ function compareWithPriority (priority: Record<string, number>, left: string, ri
|
||||
return lexCompare(left, right)
|
||||
}
|
||||
|
||||
export function sortLockfileKeys (lockfile: LockfileFileV9): LockfileFileV9 {
|
||||
export function sortLockfileKeys (lockfile: LockfileFile): LockfileFile {
|
||||
const compareRootKeys = compareWithPriority.bind(null, ROOT_KEYS_ORDER)
|
||||
if (lockfile.importers != null) {
|
||||
lockfile.importers = sortKeys(lockfile.importers)
|
||||
@@ -96,7 +92,7 @@ export function sortLockfileKeys (lockfile: LockfileFileV9): LockfileFileV9 {
|
||||
})
|
||||
}
|
||||
}
|
||||
for (const key of ['dependencies', 'devDependencies', 'optionalDependencies', 'time', 'patchedDependencies'] as const) {
|
||||
for (const key of ['time', 'patchedDependencies'] as const) {
|
||||
if (!lockfile[key]) continue
|
||||
lockfile[key] = sortKeys<any>(lockfile[key]) // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { promises as fs } from 'fs'
|
||||
import path from 'path'
|
||||
import { type LockfileFileV9, type Lockfile, type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject, type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import rimraf from '@zkochan/rimraf'
|
||||
import yaml from 'js-yaml'
|
||||
@@ -29,7 +29,7 @@ const LOCKFILE_YAML_FORMAT = {
|
||||
|
||||
export async function writeWantedLockfile (
|
||||
pkgPath: string,
|
||||
wantedLockfile: Lockfile,
|
||||
wantedLockfile: LockfileObject,
|
||||
opts?: {
|
||||
useGitBranchLockfile?: boolean
|
||||
mergeGitBranchLockfiles?: boolean
|
||||
@@ -41,7 +41,7 @@ export async function writeWantedLockfile (
|
||||
|
||||
export async function writeCurrentLockfile (
|
||||
virtualStoreDir: string,
|
||||
currentLockfile: Lockfile
|
||||
currentLockfile: LockfileObject
|
||||
): Promise<void> {
|
||||
// empty lockfile is not saved
|
||||
if (isEmptyLockfile(currentLockfile)) {
|
||||
@@ -55,13 +55,11 @@ export async function writeCurrentLockfile (
|
||||
async function writeLockfile (
|
||||
lockfileFilename: string,
|
||||
pkgPath: string,
|
||||
wantedLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
): Promise<void> {
|
||||
const lockfilePath = path.join(pkgPath, lockfileFilename)
|
||||
|
||||
const lockfileToStringify = convertToLockfileFile(wantedLockfile, {
|
||||
forceSharedFormat: true,
|
||||
})
|
||||
const lockfileToStringify = convertToLockfileFile(wantedLockfile)
|
||||
|
||||
const yamlDoc = yamlStringify(lockfileToStringify)
|
||||
|
||||
@@ -69,19 +67,19 @@ async function writeLockfile (
|
||||
}
|
||||
|
||||
function yamlStringify (lockfile: LockfileFile) {
|
||||
const sortedLockfile = sortLockfileKeys(lockfile as LockfileFileV9)
|
||||
const sortedLockfile = sortLockfileKeys(lockfile as LockfileFile)
|
||||
return yaml.dump(sortedLockfile, LOCKFILE_YAML_FORMAT)
|
||||
}
|
||||
|
||||
export function isEmptyLockfile (lockfile: Lockfile): boolean {
|
||||
export function isEmptyLockfile (lockfile: LockfileObject): boolean {
|
||||
return Object.values(lockfile.importers).every((importer) => isEmpty(importer.specifiers ?? {}) && isEmpty(importer.dependencies ?? {}))
|
||||
}
|
||||
|
||||
export async function writeLockfiles (
|
||||
opts: {
|
||||
wantedLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
wantedLockfileDir: string
|
||||
currentLockfile: Lockfile
|
||||
currentLockfile: LockfileObject
|
||||
currentLockfileDir: string
|
||||
useGitBranchLockfile?: boolean
|
||||
mergeGitBranchLockfiles?: boolean
|
||||
@@ -91,10 +89,7 @@ export async function writeLockfiles (
|
||||
const wantedLockfilePath = path.join(opts.wantedLockfileDir, wantedLockfileName)
|
||||
const currentLockfilePath = path.join(opts.currentLockfileDir, 'lock.yaml')
|
||||
|
||||
const normalizeOpts = {
|
||||
forceSharedFormat: true,
|
||||
}
|
||||
const wantedLockfileToStringify = convertToLockfileFile(opts.wantedLockfile, normalizeOpts)
|
||||
const wantedLockfileToStringify = convertToLockfileFile(opts.wantedLockfile)
|
||||
const yamlDoc = yamlStringify(wantedLockfileToStringify)
|
||||
|
||||
// in most cases the `pnpm-lock.yaml` and `node_modules/.pnpm-lock.yaml` are equal
|
||||
@@ -120,7 +115,7 @@ export async function writeLockfiles (
|
||||
prefix: opts.wantedLockfileDir,
|
||||
})
|
||||
|
||||
const currentLockfileToStringify = convertToLockfileFile(opts.currentLockfile, normalizeOpts)
|
||||
const currentLockfileToStringify = convertToLockfileFile(opts.currentLockfile)
|
||||
const currentYamlDoc = yamlStringify(currentLockfileToStringify)
|
||||
|
||||
await Promise.all([
|
||||
|
||||
17
lockfile/fs/test/fixtures/2/pnpm-lock.yaml
generated
vendored
17
lockfile/fs/test/fixtures/2/pnpm-lock.yaml
generated
vendored
@@ -1,8 +1,11 @@
|
||||
lockfileVersion: '9.0'
|
||||
dependencies:
|
||||
foo:
|
||||
version: '1.0.0'
|
||||
specifier: '1'
|
||||
dependenciesMeta:
|
||||
foo:
|
||||
injected: true
|
||||
|
||||
importers:
|
||||
.:
|
||||
dependencies:
|
||||
foo:
|
||||
version: '1.0.0'
|
||||
specifier: '1'
|
||||
dependenciesMeta:
|
||||
foo:
|
||||
injected: true
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
dependencies:
|
||||
is-positive:
|
||||
version: '2.0.0'
|
||||
specifier: '2.0.0'
|
||||
importers:
|
||||
.:
|
||||
dependencies:
|
||||
is-positive:
|
||||
version: '2.0.0'
|
||||
specifier: '2.0.0'
|
||||
|
||||
packages:
|
||||
/is-positive@2.0.0:
|
||||
is-positive@2.0.0:
|
||||
resolution: {integrity: 'sha1-ChbBDewTLAqLCzb793Fo5VDvg/g='}
|
||||
|
||||
snapshots:
|
||||
is-positive@2.0.0: {}
|
||||
|
||||
15
lockfile/fs/test/fixtures/6/pnpm-lock.yaml
generated
vendored
15
lockfile/fs/test/fixtures/6/pnpm-lock.yaml
generated
vendored
@@ -1,10 +1,15 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
dependencies:
|
||||
is-positive:
|
||||
version: '1.0.0'
|
||||
specifier: '1.0.0'
|
||||
importers:
|
||||
.:
|
||||
dependencies:
|
||||
is-positive:
|
||||
version: '1.0.0'
|
||||
specifier: '1.0.0'
|
||||
|
||||
packages:
|
||||
/is-positive@1.0.0:
|
||||
is-positive@1.0.0:
|
||||
resolution: {integrity: 'sha1-ChbBDewTLAqLCzb793Fo5VDvg/g='}
|
||||
|
||||
snapshots:
|
||||
is-positive@1.0.0: {}
|
||||
|
||||
19
lockfile/fs/test/fixtures/7/pnpm-lock.yaml
generated
vendored
19
lockfile/fs/test/fixtures/7/pnpm-lock.yaml
generated
vendored
@@ -1,12 +1,15 @@
|
||||
lockfileVersion: 5.3-inlineSpecifiers
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
specifiers: {}
|
||||
|
||||
dependencies:
|
||||
is-positive:
|
||||
specifier: '^1.0.0'
|
||||
version: '1.0.0'
|
||||
importers:
|
||||
.:
|
||||
dependencies:
|
||||
is-positive:
|
||||
specifier: '^1.0.0'
|
||||
version: '1.0.0'
|
||||
|
||||
packages:
|
||||
/is-positive/1.0.0:
|
||||
is-positive@1.0.0:
|
||||
resolution: {integrity: 'sha1-ChbBDewTLAqLCzb793Fo5VDvg/g='}
|
||||
|
||||
snapshots:
|
||||
is-positive@1.0.0: {}
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
import { convertToLockfileObject } from '../lib/lockfileFormatConverters'
|
||||
|
||||
test('convertToLockfileObject converts directory dependencies', () => {
|
||||
expect(convertToLockfileObject({
|
||||
lockfileVersion: '',
|
||||
importers: {
|
||||
'.': {
|
||||
dependencies: {
|
||||
a: {
|
||||
specifier: 'file:../a',
|
||||
version: 'file:../a',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
packages: {
|
||||
'file:../a': {
|
||||
resolution: { directory: '../a', type: 'directory' },
|
||||
name: 'a',
|
||||
dev: false,
|
||||
} as any, // eslint-disable-line
|
||||
},
|
||||
})).toMatchObject({
|
||||
lockfileVersion: '',
|
||||
importers: {
|
||||
'.': {
|
||||
dependencies: {
|
||||
a: 'file:../a',
|
||||
},
|
||||
specifiers: {
|
||||
a: 'file:../a',
|
||||
},
|
||||
},
|
||||
},
|
||||
packages: {
|
||||
'a@file:../a': {
|
||||
resolution: { directory: '../a', type: 'directory' },
|
||||
name: 'a',
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('convertToLockfileObject converts git-hosted dependencies', () => {
|
||||
expect(convertToLockfileObject({
|
||||
lockfileVersion: '',
|
||||
importers: {
|
||||
'.': {
|
||||
dependencies: {
|
||||
'is-negative': {
|
||||
specifier: 'github:kevva/is-negative',
|
||||
version: 'github.com/kevva/is-negative/1d7e288222b53a0cab90a331f1865220ec29560c',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
packages: {
|
||||
'github.com/kevva/is-negative/1d7e288222b53a0cab90a331f1865220ec29560c': {
|
||||
resolution: { tarball: 'https://codeload.github.com/kevva/is-negative/tar.gz/1d7e288222b53a0cab90a331f1865220ec29560c' },
|
||||
name: 'is-negative',
|
||||
version: '2.1.0',
|
||||
engines: { node: '>=0.10.0' },
|
||||
dev: false,
|
||||
} as any, // eslint-disable-line
|
||||
},
|
||||
})).toMatchObject({
|
||||
lockfileVersion: '',
|
||||
importers: {
|
||||
'.': {
|
||||
dependencies: {
|
||||
'is-negative': 'https://codeload.github.com/kevva/is-negative/tar.gz/1d7e288222b53a0cab90a331f1865220ec29560c',
|
||||
},
|
||||
specifiers: {
|
||||
'is-negative': 'github:kevva/is-negative',
|
||||
},
|
||||
},
|
||||
},
|
||||
packages: {
|
||||
'is-negative@https://codeload.github.com/kevva/is-negative/tar.gz/1d7e288222b53a0cab90a331f1865220ec29560c': {
|
||||
resolution: { tarball: 'https://codeload.github.com/kevva/is-negative/tar.gz/1d7e288222b53a0cab90a331f1865220ec29560c' },
|
||||
name: 'is-negative',
|
||||
version: '2.1.0',
|
||||
engines: { node: '>=0.10.0' },
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('convertToLockfileObject converts git-hosted dependencies via ssh', () => {
|
||||
const result = convertToLockfileObject({
|
||||
lockfileVersion: '',
|
||||
importers: {
|
||||
'.': {
|
||||
dependencies: {
|
||||
'git-resolver': {
|
||||
specifier: 'ssh://git@gitlab:pnpm/git-resolver#988c61e11dc8d9ca0b5580cb15291951812549dc',
|
||||
version: 'git+ssh://git@gitlab/pnpm/git-resolver#988c61e11dc8d9ca0b5580cb15291951812549dc',
|
||||
},
|
||||
foo: {
|
||||
specifier: 'https://gitlab.com/foo/foo.git',
|
||||
version: 'git@gitlab.com+foo/foo/6ae3f32d7c631f64fbaf70cdd349ae6e2cc68e6c',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
packages: {
|
||||
'git+ssh://git@gitlab/pnpm/git-resolver#988c61e11dc8d9ca0b5580cb15291951812549dc': {
|
||||
name: 'git-resolver',
|
||||
resolution: {
|
||||
commit: '988c61e11dc8d9ca0b5580cb15291951812549dc',
|
||||
repo: 'ssh://git@gitlab/pnpm/git-resolver',
|
||||
type: 'git',
|
||||
},
|
||||
} as any, // eslint-disable-line
|
||||
'git@gitlab.com+foo/foo/6ae3f32d7c631f64fbaf70cdd349ae6e2cc68e6c': {
|
||||
name: 'foo',
|
||||
resolution: {
|
||||
commit: '6ae3f32d7c631f64fbaf70cdd349ae6e2cc68e6c',
|
||||
repo: 'git@gitlab.com:foo/foo.git',
|
||||
type: 'git',
|
||||
},
|
||||
} as any, // eslint-disable-line
|
||||
},
|
||||
})
|
||||
expect(result).toMatchObject({
|
||||
lockfileVersion: '',
|
||||
importers: {
|
||||
'.': {
|
||||
dependencies: {
|
||||
foo: 'git+https://git@gitlab.com:foo/foo.git#6ae3f32d7c631f64fbaf70cdd349ae6e2cc68e6c',
|
||||
'git-resolver': 'git+ssh://git@gitlab/pnpm/git-resolver#988c61e11dc8d9ca0b5580cb15291951812549dc',
|
||||
},
|
||||
specifiers: {
|
||||
foo: 'https://gitlab.com/foo/foo.git',
|
||||
'git-resolver': 'ssh://git@gitlab:pnpm/git-resolver#988c61e11dc8d9ca0b5580cb15291951812549dc',
|
||||
},
|
||||
},
|
||||
},
|
||||
packages: {
|
||||
'git-resolver@git+ssh://git@gitlab/pnpm/git-resolver#988c61e11dc8d9ca0b5580cb15291951812549dc': {
|
||||
resolution: {
|
||||
commit: '988c61e11dc8d9ca0b5580cb15291951812549dc',
|
||||
repo: 'ssh://git@gitlab/pnpm/git-resolver',
|
||||
type: 'git',
|
||||
},
|
||||
},
|
||||
'foo@git+https://git@gitlab.com:foo/foo.git#6ae3f32d7c631f64fbaf70cdd349ae6e2cc68e6c': {
|
||||
resolution: {
|
||||
commit: '6ae3f32d7c631f64fbaf70cdd349ae6e2cc68e6c',
|
||||
repo: 'git@gitlab.com:foo/foo.git',
|
||||
type: 'git',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -87,7 +87,7 @@ test('convertToLockfileFile()', () => {
|
||||
'@registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz': {},
|
||||
},
|
||||
}
|
||||
expect(convertToLockfileFile(lockfileV5, { forceSharedFormat: false })).toEqual(lockfileV6)
|
||||
expect(convertToLockfileFile(lockfileV5)).toEqual(lockfileV6)
|
||||
expect(convertToLockfileObject(lockfileV6)).toEqual(lockfileV5)
|
||||
})
|
||||
|
||||
@@ -178,98 +178,6 @@ test('convertToLockfileFile() with lockfile v6', () => {
|
||||
'@registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz': {},
|
||||
},
|
||||
}
|
||||
expect(convertToLockfileFile(lockfileV5, { forceSharedFormat: false })).toEqual(lockfileV6)
|
||||
expect(convertToLockfileFile(lockfileV5)).toEqual(lockfileV6)
|
||||
expect(convertToLockfileObject(lockfileV6)).toEqual(lockfileV5)
|
||||
})
|
||||
|
||||
test('convertToLockfileObject() converts package IDs', () => {
|
||||
const lockfileFile = {
|
||||
lockfileVersion: '6.0',
|
||||
importers: {
|
||||
project1: {
|
||||
dependencies: {
|
||||
'is-positive': {
|
||||
specifier: 'github:kevva/is-positive',
|
||||
version: 'github.com/kevva/is-positive/97edff6f525f192a3f83cea1944765f769ae2678(@babel/core@2.0.0)',
|
||||
},
|
||||
tarball: {
|
||||
specifier: '^1.0.0',
|
||||
version: '@registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
|
||||
},
|
||||
'git-hosted': {
|
||||
specifier: 'gitlab:pnpm/git-resolver',
|
||||
version: 'gitlab/pnpm/git-resolver/988c61e11dc8d9ca0b5580cb15291951812549dc(foo@1.0.0)',
|
||||
},
|
||||
'is-odd': {
|
||||
specifier: '1.0.0',
|
||||
version: '1.0.0',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
packages: {
|
||||
'github.com/kevva/is-positive/97edff6f525f192a3f83cea1944765f769ae2678(@babel/core@2.0.0)': {
|
||||
name: 'is-positive',
|
||||
resolution: { tarball: 'https://codeload.github.com/kevva/is-positive/tar.gz/97edff6f525f192a3f83cea1944765f769ae2678' },
|
||||
},
|
||||
'@registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz': {
|
||||
name: 'is-positive',
|
||||
resolution: { tarball: 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz', integrity: '' },
|
||||
},
|
||||
'gitlab/pnpm/git-resolver/988c61e11dc8d9ca0b5580cb15291951812549dc(foo@1.0.0)': {
|
||||
id: 'gitlab/pnpm/git-resolver/988c61e11dc8d9ca0b5580cb15291951812549dc',
|
||||
name: 'git-hosted',
|
||||
resolution: {
|
||||
commit: '988c61e11dc8d9ca0b5580cb15291951812549dc',
|
||||
repo: 'ssh://git@gitlab/pnpm/git-resolver',
|
||||
type: 'git',
|
||||
},
|
||||
},
|
||||
'/is-odd@1.0.0': {
|
||||
resolution: { integrity: '' },
|
||||
},
|
||||
},
|
||||
}
|
||||
const lockfileObject = {
|
||||
lockfileVersion: '6.0',
|
||||
importers: {
|
||||
project1: {
|
||||
dependencies: {
|
||||
'is-positive': 'https://codeload.github.com/kevva/is-positive/tar.gz/97edff6f525f192a3f83cea1944765f769ae2678(@babel/core@2.0.0)',
|
||||
tarball: 'is-positive@https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
|
||||
'git-hosted': 'git+ssh://git@gitlab/pnpm/git-resolver#988c61e11dc8d9ca0b5580cb15291951812549dc(foo@1.0.0)',
|
||||
'is-odd': '1.0.0',
|
||||
},
|
||||
specifiers: {
|
||||
'is-positive': 'github:kevva/is-positive',
|
||||
tarball: '^1.0.0',
|
||||
'git-hosted': 'gitlab:pnpm/git-resolver',
|
||||
'is-odd': '1.0.0',
|
||||
},
|
||||
},
|
||||
},
|
||||
packages: {
|
||||
'is-positive@https://codeload.github.com/kevva/is-positive/tar.gz/97edff6f525f192a3f83cea1944765f769ae2678(@babel/core@2.0.0)': {
|
||||
name: 'is-positive',
|
||||
resolution: { tarball: 'https://codeload.github.com/kevva/is-positive/tar.gz/97edff6f525f192a3f83cea1944765f769ae2678' },
|
||||
},
|
||||
'is-positive@https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz': {
|
||||
name: 'is-positive',
|
||||
resolution: { tarball: 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz', integrity: '' },
|
||||
},
|
||||
'git-hosted@git+ssh://git@gitlab/pnpm/git-resolver#988c61e11dc8d9ca0b5580cb15291951812549dc(foo@1.0.0)': {
|
||||
id: 'git-hosted@git+ssh://git@gitlab/pnpm/git-resolver#988c61e11dc8d9ca0b5580cb15291951812549dc',
|
||||
name: 'git-hosted',
|
||||
resolution: {
|
||||
commit: '988c61e11dc8d9ca0b5580cb15291951812549dc',
|
||||
repo: 'ssh://git@gitlab/pnpm/git-resolver',
|
||||
type: 'git',
|
||||
},
|
||||
},
|
||||
'is-odd@1.0.0': {
|
||||
resolution: { integrity: '' },
|
||||
},
|
||||
},
|
||||
}
|
||||
expect(convertToLockfileObject(lockfileFile as any)).toEqual(lockfileObject) // eslint-disable-line
|
||||
})
|
||||
|
||||
@@ -18,8 +18,6 @@ test('empty overrides and neverBuiltDependencies are removed during lockfile nor
|
||||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
forceSharedFormat: false,
|
||||
})).toStrictEqual({
|
||||
lockfileVersion: LOCKFILE_VERSION,
|
||||
importers: {
|
||||
@@ -63,8 +61,6 @@ test('redundant fields are removed from "time"', () => {
|
||||
'/qar@1.0.0': '2021-02-11T22:54:29.120Z',
|
||||
'/zoo@1.0.0': '2021-02-11T22:54:29.120Z',
|
||||
},
|
||||
}, {
|
||||
forceSharedFormat: false,
|
||||
})).toStrictEqual({
|
||||
lockfileVersion: LOCKFILE_VERSION,
|
||||
importers: {
|
||||
|
||||
@@ -33,7 +33,6 @@ test('readWantedLockfile()', async () => {
|
||||
dependenciesMeta: {
|
||||
foo: { injected: true },
|
||||
},
|
||||
publishDirectory: undefined,
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -291,7 +290,7 @@ test('readWantedLockfile() with inlineSpecifiersFormat', async () => {
|
||||
},
|
||||
},
|
||||
packages: {
|
||||
'is-positive/1.0.0': {
|
||||
'is-positive@1.0.0': {
|
||||
resolution: {
|
||||
integrity: 'sha1-ChbBDewTLAqLCzb793Fo5VDvg/g=',
|
||||
},
|
||||
|
||||
@@ -81,6 +81,7 @@ test('writeLockfiles() when no specifiers but dependencies present', async () =>
|
||||
},
|
||||
},
|
||||
lockfileVersion: LOCKFILE_VERSION,
|
||||
packages: {},
|
||||
}
|
||||
await writeLockfiles({
|
||||
currentLockfile: wantedLockfile,
|
||||
|
||||
@@ -27,9 +27,6 @@
|
||||
{
|
||||
"path": "../../packages/types"
|
||||
},
|
||||
{
|
||||
"path": "../../resolving/git-resolver"
|
||||
},
|
||||
{
|
||||
"path": "../merger"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { promises as fs } from 'fs'
|
||||
import path from 'path'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import {
|
||||
nameVerFromPkgSnapshot,
|
||||
} from '@pnpm/lockfile.utils'
|
||||
@@ -10,7 +10,7 @@ import { generateInlinedScript, type PackageRegistry } from '@yarnpkg/pnp'
|
||||
import normalizePath from 'normalize-path'
|
||||
|
||||
export async function writePnpFile (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
opts: {
|
||||
importerNames: Record<string, string>
|
||||
lockfileDir: string
|
||||
@@ -31,7 +31,7 @@ export async function writePnpFile (
|
||||
}
|
||||
|
||||
export function lockfileToPackageRegistry (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
opts: {
|
||||
importerNames: { [importerId: string]: string }
|
||||
lockfileDir: string
|
||||
@@ -109,7 +109,7 @@ export function lockfileToPackageRegistry (
|
||||
}
|
||||
|
||||
function toPackageDependenciesMap (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
deps: {
|
||||
[depAlias: string]: string
|
||||
},
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { type Lockfile, type PackageSnapshot, type PackageSnapshots } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject, type PackageSnapshot, type PackageSnapshots } from '@pnpm/lockfile.types'
|
||||
import { type DepPath, type ProjectId } from '@pnpm/types'
|
||||
import comverToSemver from 'comver-to-semver'
|
||||
import semver from 'semver'
|
||||
|
||||
export function mergeLockfileChanges (ours: Lockfile, theirs: Lockfile): Lockfile {
|
||||
const newLockfile: Lockfile = {
|
||||
export function mergeLockfileChanges (ours: LockfileObject, theirs: LockfileObject): LockfileObject {
|
||||
const newLockfile: LockfileObject = {
|
||||
importers: {},
|
||||
lockfileVersion: semver.gt(comverToSemver(theirs.lockfileVersion.toString()), comverToSemver(ours.lockfileVersion.toString()))
|
||||
? theirs.lockfileVersion
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { type DepPath, type ProjectId } from '@pnpm/types'
|
||||
import { mergeLockfileChanges } from '../src'
|
||||
|
||||
@@ -58,7 +58,7 @@ test('picks the newer version when dependencies differ inside importer', () => {
|
||||
})
|
||||
|
||||
test('picks the newer version when dependencies differ inside package', () => {
|
||||
const base: Lockfile = {
|
||||
const base: LockfileObject = {
|
||||
importers: {
|
||||
['.' as ProjectId]: {
|
||||
dependencies: {
|
||||
|
||||
3711
lockfile/plugin-commands-audit/test/fixtures/has-vulnerabilities/pnpm-lock.yaml
generated
vendored
3711
lockfile/plugin-commands-audit/test/fixtures/has-vulnerabilities/pnpm-lock.yaml
generated
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
import { LOCKFILE_VERSION } from '@pnpm/constants'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type PackageSnapshots,
|
||||
type ProjectSnapshot,
|
||||
type ResolvedDependencies,
|
||||
@@ -17,12 +17,12 @@ export * from '@pnpm/lockfile.types'
|
||||
type DependenciesGraph = Record<DepPath, { optional?: boolean }>
|
||||
|
||||
export function pruneSharedLockfile (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
opts?: {
|
||||
dependenciesGraph?: DependenciesGraph
|
||||
warn?: (msg: string) => void
|
||||
}
|
||||
): Lockfile {
|
||||
): LockfileObject {
|
||||
const copiedPackages = (lockfile.packages == null)
|
||||
? {}
|
||||
: copyPackageSnapshots(lockfile.packages, {
|
||||
@@ -33,7 +33,7 @@ export function pruneSharedLockfile (
|
||||
dependenciesGraph: opts?.dependenciesGraph,
|
||||
})
|
||||
|
||||
const prunedLockfile: Lockfile = {
|
||||
const prunedLockfile: LockfileObject = {
|
||||
...lockfile,
|
||||
packages: copiedPackages,
|
||||
}
|
||||
@@ -44,14 +44,14 @@ export function pruneSharedLockfile (
|
||||
}
|
||||
|
||||
export function pruneLockfile (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
pkg: PackageManifest,
|
||||
importerId: ProjectId,
|
||||
opts: {
|
||||
warn?: (msg: string) => void
|
||||
dependenciesGraph?: DependenciesGraph
|
||||
}
|
||||
): Lockfile {
|
||||
): LockfileObject {
|
||||
const importer = lockfile.importers[importerId]
|
||||
const lockfileSpecs: ResolvedDependencies = importer.specifiers ?? {}
|
||||
const optionalDependencies = Object.keys(pkg.optionalDependencies ?? {})
|
||||
@@ -94,7 +94,7 @@ export function pruneLockfile (
|
||||
const updatedImporter: ProjectSnapshot = {
|
||||
specifiers,
|
||||
}
|
||||
const prunedLockfile: Lockfile = {
|
||||
const prunedLockfile: LockfileObject = {
|
||||
importers: {
|
||||
...lockfile.importers,
|
||||
[importerId]: updatedImporter,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Lockfile, type PatchFile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject, type PatchFile } from '@pnpm/lockfile.types'
|
||||
import equals from 'ramda/src/equals'
|
||||
|
||||
export type ChangedField =
|
||||
@@ -13,7 +13,7 @@ export type ChangedField =
|
||||
| 'pnpmfileChecksum'
|
||||
|
||||
export function getOutdatedLockfileSetting (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
{
|
||||
overrides,
|
||||
packageExtensionsChecksum,
|
||||
|
||||
@@ -12,7 +12,7 @@ export interface LockfileSettings {
|
||||
injectWorkspacePackages?: boolean
|
||||
}
|
||||
|
||||
export interface Lockfile {
|
||||
export interface LockfileObject {
|
||||
importers: Record<ProjectId, ProjectSnapshot>
|
||||
lockfileVersion: string
|
||||
time?: Record<string, string>
|
||||
@@ -26,27 +26,50 @@ export interface Lockfile {
|
||||
settings?: LockfileSettings
|
||||
}
|
||||
|
||||
export interface LockfileV9 {
|
||||
importers: Record<string, ProjectSnapshot>
|
||||
lockfileVersion: string
|
||||
time?: Record<string, string>
|
||||
snapshots?: Record<string, PackageSnapshotV7>
|
||||
packages?: Record<string, PackageInfo>
|
||||
neverBuiltDependencies?: string[]
|
||||
onlyBuiltDependencies?: string[]
|
||||
overrides?: Record<string, string>
|
||||
packageExtensionsChecksum?: string
|
||||
patchedDependencies?: Record<string, PatchFile>
|
||||
settings?: LockfileSettings
|
||||
export interface LockfilePackageSnapshot {
|
||||
optional?: true
|
||||
dependencies?: ResolvedDependencies
|
||||
optionalDependencies?: ResolvedDependencies
|
||||
transitivePeerDependencies?: string[]
|
||||
}
|
||||
|
||||
export interface ProjectSnapshot {
|
||||
export interface LockfilePackageInfo {
|
||||
id?: string
|
||||
patched?: true
|
||||
hasBin?: true
|
||||
// name and version are only needed
|
||||
// for packages that are hosted not in the npm registry
|
||||
name?: string
|
||||
version?: string
|
||||
resolution: LockfileResolution
|
||||
peerDependencies?: {
|
||||
[name: string]: string
|
||||
}
|
||||
peerDependenciesMeta?: {
|
||||
[name: string]: {
|
||||
optional: true
|
||||
}
|
||||
}
|
||||
bundledDependencies?: string[] | boolean
|
||||
engines?: Record<string, string> & {
|
||||
node: string
|
||||
}
|
||||
os?: string[]
|
||||
cpu?: string[]
|
||||
libc?: string[]
|
||||
deprecated?: string
|
||||
}
|
||||
|
||||
export interface ProjectSnapshotBase {
|
||||
dependenciesMeta?: DependenciesMeta
|
||||
publishDirectory?: string
|
||||
}
|
||||
|
||||
export interface ProjectSnapshot extends ProjectSnapshotBase {
|
||||
specifiers: ResolvedDependencies
|
||||
dependencies?: ResolvedDependencies
|
||||
optionalDependencies?: ResolvedDependencies
|
||||
devDependencies?: ResolvedDependencies
|
||||
dependenciesMeta?: DependenciesMeta
|
||||
publishDirectory?: string
|
||||
}
|
||||
|
||||
export type ResolvedDependenciesOfImporters = Record<string, { version: string, specifier: string }>
|
||||
@@ -92,40 +115,7 @@ export type LockfileResolution = Resolution | {
|
||||
integrity: string
|
||||
}
|
||||
|
||||
export type PackageSnapshotV7 = Pick<PackageSnapshot, 'optional' | 'dependencies' | 'optionalDependencies' | 'transitivePeerDependencies'>
|
||||
|
||||
export type PackageInfo = Pick<PackageSnapshot, 'id' | 'patched' | 'hasBin' | 'name' | 'version' | 'resolution' | 'peerDependencies' | 'peerDependenciesMeta' | 'bundledDependencies' | 'engines' | 'cpu' | 'os' | 'libc' | 'deprecated'>
|
||||
|
||||
export interface PackageSnapshot {
|
||||
id?: string
|
||||
optional?: true
|
||||
patched?: true
|
||||
hasBin?: true
|
||||
// name and version are only needed
|
||||
// for packages that are hosted not in the npm registry
|
||||
name?: string
|
||||
version?: string
|
||||
resolution: LockfileResolution
|
||||
dependencies?: ResolvedDependencies
|
||||
optionalDependencies?: ResolvedDependencies
|
||||
peerDependencies?: {
|
||||
[name: string]: string
|
||||
}
|
||||
peerDependenciesMeta?: {
|
||||
[name: string]: {
|
||||
optional: true
|
||||
}
|
||||
}
|
||||
transitivePeerDependencies?: string[]
|
||||
bundledDependencies?: string[] | boolean
|
||||
engines?: Record<string, string> & {
|
||||
node: string
|
||||
}
|
||||
os?: string[]
|
||||
cpu?: string[]
|
||||
libc?: string[]
|
||||
deprecated?: string
|
||||
}
|
||||
export type PackageSnapshot = LockfilePackageInfo & LockfilePackageSnapshot
|
||||
|
||||
export interface Dependencies {
|
||||
[name: string]: string
|
||||
|
||||
@@ -1,28 +1,9 @@
|
||||
import type { Lockfile, PackageSnapshot, ProjectSnapshot } from '.'
|
||||
import type { DependenciesMeta } from '@pnpm/types'
|
||||
import { type LockfileObject, type LockfilePackageInfo, type LockfilePackageSnapshot, type ProjectSnapshotBase } from '.'
|
||||
|
||||
export type LockfileFile = Omit<InlineSpecifiersLockfile, 'importers'> &
|
||||
Partial<InlineSpecifiersProjectSnapshot> &
|
||||
Partial<Pick<InlineSpecifiersLockfile, 'importers'>>
|
||||
|
||||
export type LockfileFileV9 = Omit<InlineSpecifiersLockfile, 'importers' | 'packages'> &
|
||||
Partial<InlineSpecifiersProjectSnapshot> &
|
||||
Partial<Pick<InlineSpecifiersLockfile, 'importers'>> & {
|
||||
packages?: Record<string, Pick<PackageSnapshot, 'resolution' | 'engines' | 'cpu' | 'os' | 'hasBin' | 'name' | 'version' | 'bundledDependencies' | 'peerDependencies' | 'peerDependenciesMeta' | 'deprecated'>>
|
||||
snapshots?: Record<string, Pick<PackageSnapshot, 'dependencies' | 'optionalDependencies' | 'patched' | 'optional' | 'transitivePeerDependencies' | 'id'>>
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to the current Lockfile importers format (lockfile version 5.4 at
|
||||
* time of writing), but specifiers are moved to each ResolvedDependencies block
|
||||
* instead of being declared on its own dictionary.
|
||||
*
|
||||
* This is an experiment to reduce one flavor of merge conflicts in lockfiles.
|
||||
* For more info: https://github.com/pnpm/pnpm/issues/4725.
|
||||
*/
|
||||
export interface InlineSpecifiersLockfile extends Omit<Lockfile, 'lockfileVersion' | 'importers'> {
|
||||
lockfileVersion: string
|
||||
export type LockfileFile = Omit<LockfileObject, 'importers' | 'packages'> & {
|
||||
importers?: Record<string, InlineSpecifiersProjectSnapshot>
|
||||
packages?: Record<string, LockfilePackageInfo>
|
||||
snapshots?: Record<string, LockfilePackageSnapshot>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,11 +11,10 @@ export interface InlineSpecifiersLockfile extends Omit<Lockfile, 'lockfileVersio
|
||||
* field in favor of inlining each specifier next to its version resolution in
|
||||
* dependency blocks.
|
||||
*/
|
||||
export type InlineSpecifiersProjectSnapshot = Omit<ProjectSnapshot, 'dependencies' | 'devDependencies' | 'optionalDependencies' | 'dependenciesMeta' | 'specifiers'> & {
|
||||
export interface InlineSpecifiersProjectSnapshot extends ProjectSnapshotBase {
|
||||
dependencies?: InlineSpecifiersResolvedDependencies
|
||||
devDependencies?: InlineSpecifiersResolvedDependencies
|
||||
optionalDependencies?: InlineSpecifiersResolvedDependencies
|
||||
dependenciesMeta?: DependenciesMeta
|
||||
}
|
||||
|
||||
export interface InlineSpecifiersResolvedDependencies {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from 'path'
|
||||
import { type Lockfile, type TarballResolution } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject, type TarballResolution } from '@pnpm/lockfile.types'
|
||||
import { depPathToFilename } from '@pnpm/dependency-path'
|
||||
import { type ProjectId, type DepPath } from '@pnpm/types'
|
||||
import { packageIdFromSnapshot } from './packageIdFromSnapshot'
|
||||
@@ -9,7 +9,7 @@ type GetLocalLocations = (depPath: DepPath, pkgName: string) => string[]
|
||||
|
||||
export function extendProjectsWithTargetDirs<T> (
|
||||
projects: Array<T & { id: ProjectId }>,
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
ctx: {
|
||||
virtualStoreDir: string
|
||||
pkgLocationsByDepPath?: Record<DepPath, string[]>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { type Catalogs } from '@pnpm/catalogs.types'
|
||||
import { type ProjectOptions } from '@pnpm/get-context'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type ProjectSnapshot,
|
||||
} from '@pnpm/lockfile.types'
|
||||
import { refIsLocalTarball } from '@pnpm/lockfile.utils'
|
||||
@@ -22,7 +22,7 @@ export async function allProjectsAreUpToDate (
|
||||
autoInstallPeers: boolean
|
||||
excludeLinksFromLockfile: boolean
|
||||
linkWorkspacePackages: boolean
|
||||
wantedLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
workspacePackages: WorkspacePackages
|
||||
lockfileDir: string
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { type WorkspacePackages } from '@pnpm/resolver-base'
|
||||
import { type DependencyManifest, type ProjectId, type ProjectRootDir } from '@pnpm/types'
|
||||
import { allProjectsAreUpToDate } from '@pnpm/lockfile.verification'
|
||||
import { writeFile, mkdir } from 'fs/promises'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
|
||||
const fooManifest = {
|
||||
name: 'foo',
|
||||
@@ -436,7 +436,7 @@ describe('local file dependency', () => {
|
||||
},
|
||||
},
|
||||
lockfileVersion: LOCKFILE_VERSION,
|
||||
} as Lockfile,
|
||||
} as LockfileObject,
|
||||
workspacePackages,
|
||||
lockfileDir: process.cwd(),
|
||||
}
|
||||
@@ -526,7 +526,7 @@ test('allProjectsAreUpToDate(): returns true if workspace dependency\'s version
|
||||
},
|
||||
},
|
||||
lockfileVersion: LOCKFILE_VERSION,
|
||||
} as Lockfile,
|
||||
} as LockfileObject,
|
||||
workspacePackages,
|
||||
lockfileDir: process.cwd(),
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Lockfile, type PackageSnapshot } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject, type PackageSnapshot } from '@pnpm/lockfile.types'
|
||||
import { type DependenciesField, type DepPath, type ProjectId } from '@pnpm/types'
|
||||
import * as dp from '@pnpm/dependency-path'
|
||||
|
||||
@@ -15,7 +15,7 @@ export interface LockfileWalkerStep {
|
||||
}
|
||||
|
||||
export function lockfileWalkerGroupImporterSteps (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
importerIds: ProjectId[],
|
||||
opts?: {
|
||||
include?: { [dependenciesField in DependenciesField]: boolean }
|
||||
@@ -53,7 +53,7 @@ export interface LockfileWalker {
|
||||
}
|
||||
|
||||
export function lockfileWalker (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
importerIds: ProjectId[],
|
||||
opts?: {
|
||||
include?: { [dependenciesField in DependenciesField]: boolean }
|
||||
@@ -91,7 +91,7 @@ export function lockfileWalker (
|
||||
function step (
|
||||
ctx: {
|
||||
includeOptionalDependencies: boolean
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
walked: Set<DepPath>
|
||||
},
|
||||
nextDepPaths: DepPath[]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// cspell:ignore ents
|
||||
import fs from 'fs'
|
||||
import { getIndexFilePathInCafs, getFilePathByModeInCafs, type PackageFilesIndex } from '@pnpm/store.cafs'
|
||||
import { type Lockfile, readWantedLockfile, type PackageSnapshot, type TarballResolution } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject, readWantedLockfile, type PackageSnapshot, type TarballResolution } from '@pnpm/lockfile.fs'
|
||||
import {
|
||||
nameVerFromPkgSnapshot,
|
||||
} from '@pnpm/lockfile.utils'
|
||||
@@ -38,7 +38,7 @@ export async function createFuseHandlers (lockfileDir: string, storeDir: string)
|
||||
return createFuseHandlersFromLockfile(lockfile, storeDir)
|
||||
}
|
||||
|
||||
export function createFuseHandlersFromLockfile (lockfile: Lockfile, storeDir: string): FuseHandlers {
|
||||
export function createFuseHandlersFromLockfile (lockfile: LockfileObject, storeDir: string): FuseHandlers {
|
||||
const pkgSnapshotCache = new Map<string, { name: string, version: string, pkgSnapshot: PackageSnapshot, index: PackageFilesIndex }>()
|
||||
const virtualNodeModules = makeVirtualNodeModules(lockfile)
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from 'path'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import { DEPENDENCIES_FIELDS, type ProjectId } from '@pnpm/types'
|
||||
import { nameVerFromPkgSnapshot } from '@pnpm/lockfile.utils'
|
||||
import * as dp from '@pnpm/dependency-path'
|
||||
@@ -18,7 +18,7 @@ type DirEntry = {
|
||||
target: string
|
||||
} | DirDirEntry
|
||||
|
||||
export function makeVirtualNodeModules (lockfile: Lockfile): DirEntry {
|
||||
export function makeVirtualNodeModules (lockfile: LockfileObject): DirEntry {
|
||||
const entries: Record<string, DirEntry> = {
|
||||
'.pnpm': {
|
||||
entryType: 'directory',
|
||||
@@ -40,7 +40,7 @@ export function makeVirtualNodeModules (lockfile: Lockfile): DirEntry {
|
||||
}
|
||||
}
|
||||
|
||||
function createVirtualStoreDir (lockfile: Lockfile): Record<string, DirEntry> {
|
||||
function createVirtualStoreDir (lockfile: LockfileObject): Record<string, DirEntry> {
|
||||
const rootDir = {} as Record<string, DirEntry>
|
||||
for (const [depPath, pkgSnapshot] of Object.entries(lockfile.packages ?? {})) {
|
||||
const { name } = nameVerFromPkgSnapshot(depPath, pkgSnapshot)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ENGINE_NAME } from '@pnpm/constants'
|
||||
import { getPkgIdWithPatchHash, refToRelative } from '@pnpm/dependency-path'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { type DepPath, type PkgIdWithPatchHash } from '@pnpm/types'
|
||||
import { hashObjectWithoutSorting } from '@pnpm/crypto.object-hasher'
|
||||
import sortKeys from 'sort-keys'
|
||||
@@ -64,7 +64,7 @@ function calcDepStateObj<T extends string> (
|
||||
return cache[depPath]
|
||||
}
|
||||
|
||||
export function lockfileToDepGraph (lockfile: Lockfile): DepsGraph<DepPath> {
|
||||
export function lockfileToDepGraph (lockfile: LockfileObject): DepsGraph<DepPath> {
|
||||
const graph: DepsGraph<DepPath> = {}
|
||||
if (lockfile.packages != null) {
|
||||
for (const [depPath, pkgSnapshot] of Object.entries(lockfile.packages)) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { PnpmError } from '@pnpm/error'
|
||||
import { type ProjectOptions } from '@pnpm/get-context'
|
||||
import { type HoistingLimits } from '@pnpm/headless'
|
||||
import { createReadPackageHook } from '@pnpm/hooks.read-package-hook'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import { type IncludedDependencies } from '@pnpm/modules-yaml'
|
||||
import { normalizeRegistries, DEFAULT_REGISTRIES } from '@pnpm/normalize-registries'
|
||||
import { type WorkspacePackages } from '@pnpm/resolver-base'
|
||||
@@ -47,7 +47,7 @@ export interface StrictInstallOptions {
|
||||
ignorePackageManifest: boolean
|
||||
preferFrozenLockfile: boolean
|
||||
saveWorkspaceProtocol: boolean | 'rolling'
|
||||
lockfileCheck?: (prev: Lockfile, next: Lockfile) => void
|
||||
lockfileCheck?: (prev: LockfileObject, next: LockfileObject) => void
|
||||
lockfileIncludeTarballUrl: boolean
|
||||
preferWorkspacePackages: boolean
|
||||
preserveWorkspaceProtocol: boolean
|
||||
@@ -83,7 +83,7 @@ export interface StrictInstallOptions {
|
||||
hooks: {
|
||||
readPackage?: ReadPackageHook[]
|
||||
preResolution?: (ctx: PreResolutionHookContext) => Promise<void>
|
||||
afterAllResolved?: Array<(lockfile: Lockfile) => Lockfile | Promise<Lockfile>>
|
||||
afterAllResolved?: Array<(lockfile: LockfileObject) => LockfileObject | Promise<LockfileObject>>
|
||||
calculatePnpmfileChecksum?: () => Promise<string | undefined>
|
||||
}
|
||||
sideEffectsCacheRead: boolean
|
||||
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
import { linkBins, linkBinsOfPackages } from '@pnpm/link-bins'
|
||||
import {
|
||||
type ProjectSnapshot,
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
writeCurrentLockfile,
|
||||
writeLockfiles,
|
||||
writeWantedLockfile,
|
||||
@@ -730,7 +730,7 @@ function forgetResolutionsOfPrevWantedDeps (
|
||||
}
|
||||
}
|
||||
|
||||
function forgetResolutionsOfAllPrevWantedDeps (wantedLockfile: Lockfile): void {
|
||||
function forgetResolutionsOfAllPrevWantedDeps (wantedLockfile: LockfileObject): void {
|
||||
// Similar to the forgetResolutionsOfPrevWantedDeps function above, we can
|
||||
// delete existing resolutions in importers to make sure they're resolved
|
||||
// again.
|
||||
@@ -815,7 +815,7 @@ export interface UpdatedProject {
|
||||
}
|
||||
|
||||
interface InstallFunctionResult {
|
||||
newLockfile: Lockfile
|
||||
newLockfile: LockfileObject
|
||||
projects: UpdatedProject[]
|
||||
stats?: InstallationResultStats
|
||||
depsRequiringBuild: DepPath[]
|
||||
@@ -1020,7 +1020,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
|
||||
})
|
||||
|
||||
newLockfile = ((opts.hooks?.afterAllResolved) != null)
|
||||
? await pipeWith(async (f, res) => f(await res), opts.hooks.afterAllResolved as any)(newLockfile) as Lockfile // eslint-disable-line
|
||||
? await pipeWith(async (f, res) => f(await res), opts.hooks.afterAllResolved as any)(newLockfile) as LockfileObject // eslint-disable-line
|
||||
: newLockfile
|
||||
|
||||
if (opts.updateLockfileMinorVersion) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
import { linkDirectDeps } from '@pnpm/pkg-manager.direct-dep-linker'
|
||||
import { type InstallationResultStats } from '@pnpm/headless'
|
||||
import { hoist, type HoistedWorkspaceProject } from '@pnpm/hoist'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import { logger } from '@pnpm/logger'
|
||||
import { prune } from '@pnpm/modules-cleaner'
|
||||
import { type IncludedDependencies } from '@pnpm/modules-yaml'
|
||||
@@ -44,7 +44,7 @@ import { type ImporterToUpdate } from './index'
|
||||
const brokenModulesLogger = logger('_broken_node_modules')
|
||||
|
||||
export interface LinkPackagesOptions {
|
||||
currentLockfile: Lockfile
|
||||
currentLockfile: LockfileObject
|
||||
dedupeDirectDeps: boolean
|
||||
dependenciesByProjectId: Record<string, Map<string, DepPath>>
|
||||
disableRelinkLocalDirDeps?: boolean
|
||||
@@ -71,13 +71,13 @@ export interface LinkPackagesOptions {
|
||||
storeController: StoreController
|
||||
virtualStoreDir: string
|
||||
virtualStoreDirMaxLength: number
|
||||
wantedLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
wantedToBeSkippedPackageIds: Set<string>
|
||||
hoistWorkspacePackages?: boolean
|
||||
}
|
||||
|
||||
export interface LinkPackagesResult {
|
||||
currentLockfile: Lockfile
|
||||
currentLockfile: LockfileObject
|
||||
newDepPaths: DepPath[]
|
||||
newHoistedDependencies: HoistedDependencies
|
||||
removedDepPaths: Set<string>
|
||||
@@ -167,7 +167,7 @@ export async function linkPackages (projects: ImporterToUpdate[], depGraph: Depe
|
||||
stage: 'importing_done',
|
||||
})
|
||||
|
||||
let currentLockfile: Lockfile
|
||||
let currentLockfile: LockfileObject
|
||||
const allImportersIncluded = equals(projectIds.sort(), Object.keys(opts.wantedLockfile.importers).sort())
|
||||
if (
|
||||
opts.makePartialCurrentLockfile ||
|
||||
@@ -333,8 +333,8 @@ interface LinkNewPackagesResult {
|
||||
}
|
||||
|
||||
async function linkNewPackages (
|
||||
currentLockfile: Lockfile,
|
||||
wantedLockfile: Lockfile,
|
||||
currentLockfile: LockfileObject,
|
||||
wantedLockfile: LockfileObject,
|
||||
depGraph: DependenciesGraph,
|
||||
opts: LinkNewPackagesOptions
|
||||
): Promise<LinkNewPackagesResult> {
|
||||
@@ -407,7 +407,7 @@ async function linkNewPackages (
|
||||
|
||||
async function selectNewFromWantedDeps (
|
||||
wantedRelDepPaths: DepPath[],
|
||||
currentLockfile: Lockfile,
|
||||
currentLockfile: LockfileObject,
|
||||
depGraph: DependenciesGraph
|
||||
): Promise<Set<DepPath>> {
|
||||
const newDeps = new Set<DepPath>()
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
type MutatedProject,
|
||||
type ProjectOptions,
|
||||
} from '@pnpm/core'
|
||||
import { type Lockfile, type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject, type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { type ProjectRootDir, type ProjectId } from '@pnpm/types'
|
||||
import { prepareEmpty, preparePackages, tempDir } from '@pnpm/prepare'
|
||||
import { addDistTag } from '@pnpm/registry-mock'
|
||||
@@ -213,7 +213,7 @@ test('update the lockfile when a new project is added to the workspace but do no
|
||||
})
|
||||
await mutateModules(importers, testDefaults({ allProjects, excludeLinksFromLockfile: true, frozenLockfile: true }))
|
||||
|
||||
const lockfile: Lockfile = readYamlFile(WANTED_LOCKFILE)
|
||||
const lockfile: LockfileObject = readYamlFile(WANTED_LOCKFILE)
|
||||
expect(Object.keys(lockfile.importers)).toStrictEqual(['project-1', 'project-2'])
|
||||
expect(Object.keys(lockfile.importers['project-1' as ProjectId].dependencies ?? {})).toStrictEqual(['is-positive'])
|
||||
})
|
||||
|
||||
@@ -4,7 +4,7 @@ import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { install, type MutatedProject, mutateModules } from '@pnpm/core'
|
||||
import { sync as writeYamlFile } from 'write-yaml-file'
|
||||
import { sync as readYamlFile } from 'read-yaml-file'
|
||||
import { type LockfileV9 as Lockfile, type PackageSnapshots } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileFile, type PackageSnapshots } from '@pnpm/lockfile.fs'
|
||||
import { type ProjectRootDir } from '@pnpm/types'
|
||||
import { testDefaults } from '../utils'
|
||||
|
||||
@@ -49,7 +49,7 @@ test('fix broken lockfile with --fix-lockfile', async () => {
|
||||
},
|
||||
}, testDefaults({ fixLockfile: true }))
|
||||
|
||||
const lockfile: Lockfile = readYamlFile(WANTED_LOCKFILE)
|
||||
const lockfile: LockfileFile = readYamlFile(WANTED_LOCKFILE)
|
||||
expect(Object.keys(lockfile.packages as PackageSnapshots).length).toBe(2)
|
||||
expect(lockfile.packages?.['@types/semver@5.3.31']).toBeTruthy()
|
||||
expect(lockfile.packages?.['@types/semver@5.3.31']?.resolution).toEqual({
|
||||
@@ -203,7 +203,7 @@ test('--fix-lockfile should preserve all locked dependencies version', async ()
|
||||
],
|
||||
}))
|
||||
|
||||
const lockfile: Lockfile = readYamlFile(WANTED_LOCKFILE)
|
||||
const lockfile: LockfileFile = readYamlFile(WANTED_LOCKFILE)
|
||||
|
||||
expect(Object.keys(lockfile.packages as PackageSnapshots).length).toBe(5)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { LOCKFILE_VERSION } from '@pnpm/constants'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { addDistTag } from '@pnpm/registry-mock'
|
||||
import {
|
||||
@@ -26,7 +26,7 @@ test('readPackage, afterAllResolved hooks', async () => {
|
||||
return manifest
|
||||
}
|
||||
|
||||
const afterAllResolved = jest.fn((lockfile: Lockfile) => {
|
||||
const afterAllResolved = jest.fn((lockfile: LockfileObject) => {
|
||||
Object.assign(lockfile, { foo: 'foo' })
|
||||
return lockfile
|
||||
})
|
||||
@@ -64,7 +64,7 @@ test('readPackage, afterAllResolved async hooks', async () => {
|
||||
return manifest
|
||||
}
|
||||
|
||||
const afterAllResolved = jest.fn(async (lockfile: Lockfile) => {
|
||||
const afterAllResolved = jest.fn(async (lockfile: LockfileObject) => {
|
||||
Object.assign(lockfile, { foo: 'foo' })
|
||||
return lockfile
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { LOCKFILE_VERSION } from '@pnpm/constants'
|
||||
import { type LockfileV9 as Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.fs'
|
||||
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { addDistTag } from '@pnpm/registry-mock'
|
||||
import { fixtures } from '@pnpm/test-fixtures'
|
||||
@@ -313,7 +313,7 @@ test('deep local', async () => {
|
||||
process.chdir('project-1')
|
||||
await install(manifest1, testDefaults())
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>('pnpm-lock.yaml')
|
||||
const lockfile = readYamlFile<LockfileFile>('pnpm-lock.yaml')
|
||||
expect(Object.keys(lockfile.packages ?? {})).toStrictEqual(['project-2@file:../project-2', 'project-3@file:../project-2/project-3'])
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from 'path'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { fixtures } from '@pnpm/test-fixtures'
|
||||
import { sync as readYamlFile } from 'read-yaml-file'
|
||||
@@ -18,7 +18,7 @@ test.skip('subsequent installation uses same lockfile directory by default', asy
|
||||
|
||||
await addDependenciesToPackage(manifest, ['is-negative@1.0.0'], testDefaults())
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileObject>(path.resolve('..', WANTED_LOCKFILE))
|
||||
|
||||
expect(Object.keys(lockfile.packages ?? {})).toStrictEqual(['is-negative/1.0.0', 'is-positive/1.0.0'])
|
||||
})
|
||||
@@ -54,7 +54,7 @@ test(`tarball location is correctly saved to ${WANTED_LOCKFILE} when a shared ${
|
||||
rootDir: process.cwd() as ProjectRootDir,
|
||||
}, testDefaults({ lockfileDir }))
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileObject>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.packages!['tar-pkg-with-dep@file:project/pkg.tgz' as DepPath]).toBeTruthy()
|
||||
expect(lockfile.packages!['tar-pkg-with-dep@file:project/pkg.tgz' as DepPath].resolution).toHaveProperty(['tarball'], 'file:project/pkg.tgz')
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { type LockfileV9 as Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.fs'
|
||||
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { type ProjectRootDir } from '@pnpm/types'
|
||||
import deepRequireCwd from 'deep-require-cwd'
|
||||
@@ -257,7 +257,7 @@ test('optional subdependency is not removed from current lockfile when new depen
|
||||
const modulesInfo = readYamlFile<{ skipped: string[] }>(path.join('node_modules', '.modules.yaml'))
|
||||
expect(modulesInfo.skipped).toStrictEqual(['@pnpm.e2e/dep-of-optional-pkg@1.0.0', '@pnpm.e2e/not-compatible-with-any-os@1.0.0'])
|
||||
|
||||
const currentLockfile = readYamlFile<Lockfile>(path.resolve('node_modules/.pnpm/lock.yaml'))
|
||||
const currentLockfile = readYamlFile<LockfileFile>(path.resolve('node_modules/.pnpm/lock.yaml'))
|
||||
expect(currentLockfile.packages).toHaveProperty(['@pnpm.e2e/not-compatible-with-any-os@1.0.0'])
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ test('optional subdependency is not removed from current lockfile when new depen
|
||||
], testDefaults({ allProjects, fastUnpack: false, hoistPattern: ['*'] }))
|
||||
|
||||
{
|
||||
const currentLockfile = readYamlFile<Lockfile>(path.resolve('node_modules/.pnpm/lock.yaml'))
|
||||
const currentLockfile = readYamlFile<LockfileFile>(path.resolve('node_modules/.pnpm/lock.yaml'))
|
||||
expect(currentLockfile.packages).toHaveProperty(['@pnpm.e2e/not-compatible-with-any-os@1.0.0'])
|
||||
}
|
||||
})
|
||||
|
||||
@@ -6,7 +6,7 @@ import { prepare, prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { addDistTag } from '@pnpm/registry-mock'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { type MutatedProject, type ProjectOptions, addDependenciesToPackage, mutateModulesInSingleProject, mutateModules } from '@pnpm/core'
|
||||
import { type LockfileFileV9 } from '@pnpm/lockfile.types'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { type ProjectRootDir, type ProjectManifest } from '@pnpm/types'
|
||||
import { testDefaults } from '../utils'
|
||||
|
||||
@@ -206,7 +206,7 @@ test('overrides with local file and link specs', async () => {
|
||||
},
|
||||
})
|
||||
|
||||
const lockfile = readYamlFile<LockfileFileV9>(WANTED_LOCKFILE)
|
||||
const lockfile = readYamlFile<LockfileFile>(WANTED_LOCKFILE)
|
||||
|
||||
expect(lockfile.importers?.['packages/direct']).toStrictEqual({
|
||||
dependencies: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { type LockfileV9 as Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.fs'
|
||||
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { fixtures } from '@pnpm/test-fixtures'
|
||||
@@ -160,15 +160,15 @@ test('the right peer dependency is used in every workspace package', async () =>
|
||||
strictPeerDependencies: false,
|
||||
}))
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve(WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve(WANTED_LOCKFILE))
|
||||
|
||||
expect(lockfile.importers['project-1'].dependencies).toStrictEqual({
|
||||
expect(lockfile.importers?.['project-1'].dependencies).toStrictEqual({
|
||||
'ajv-keywords': {
|
||||
specifier: '1.5.0',
|
||||
version: '1.5.0',
|
||||
},
|
||||
})
|
||||
expect(lockfile.importers['project-2'].dependencies).toStrictEqual({
|
||||
expect(lockfile.importers?.['project-2'].dependencies).toStrictEqual({
|
||||
ajv: {
|
||||
specifier: '4.10.4',
|
||||
version: '4.10.4',
|
||||
@@ -714,9 +714,9 @@ test('peer dependency is grouped with dependent when the peer is a top dependenc
|
||||
|
||||
expect(fs.existsSync(path.join('../node_modules/.pnpm/ajv-keywords@1.5.0_ajv@4.10.4/node_modules/ajv-keywords'))).toBeTruthy()
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(path.join('..', WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileFile>(path.join('..', WANTED_LOCKFILE))
|
||||
|
||||
expect(lockfile.importers.project).toStrictEqual({
|
||||
expect(lockfile.importers?.project).toStrictEqual({
|
||||
dependencies: {
|
||||
ajv: {
|
||||
specifier: '4.10.4',
|
||||
@@ -760,8 +760,8 @@ test('peer dependency is grouped with dependent when the peer is a top dependenc
|
||||
let manifest = await addDependenciesToPackage({}, ['ajv@4.10.4', 'ajv-keywords@1.5.0'], testDefaults({ lockfileDir, strictPeerDependencies: false }))
|
||||
|
||||
{
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers._).toStrictEqual({
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers?._).toStrictEqual({
|
||||
dependencies: {
|
||||
ajv: {
|
||||
specifier: '4.10.4',
|
||||
@@ -778,8 +778,8 @@ test('peer dependency is grouped with dependent when the peer is a top dependenc
|
||||
manifest = await install(manifest, testDefaults({ lockfileDir, strictPeerDependencies: false }))
|
||||
|
||||
{
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers._).toStrictEqual({
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers?._).toStrictEqual({
|
||||
dependencies: {
|
||||
ajv: {
|
||||
specifier: '4.10.4',
|
||||
@@ -807,8 +807,8 @@ test('peer dependency is grouped with dependent when the peer is a top dependenc
|
||||
)
|
||||
|
||||
{
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers._).toStrictEqual({
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers?._).toStrictEqual({
|
||||
dependencies: {
|
||||
'ajv-keywords': {
|
||||
specifier: '1.5.0',
|
||||
@@ -828,8 +828,8 @@ test('external lockfile: peer dependency is grouped with dependent even after a
|
||||
const manifest = await addDependenciesToPackage({}, ['ajv@4.10.4', 'ajv-keywords@1.4.0'], testDefaults({ lockfileDir }))
|
||||
|
||||
{
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers._).toStrictEqual({
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers?._).toStrictEqual({
|
||||
dependencies: {
|
||||
ajv: {
|
||||
specifier: '4.10.4',
|
||||
@@ -846,8 +846,8 @@ test('external lockfile: peer dependency is grouped with dependent even after a
|
||||
await addDependenciesToPackage(manifest, ['ajv-keywords@1.5.0'], testDefaults({ lockfileDir }))
|
||||
|
||||
{
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers._).toStrictEqual({
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers?._).toStrictEqual({
|
||||
dependencies: {
|
||||
ajv: {
|
||||
specifier: '4.10.4',
|
||||
@@ -871,8 +871,8 @@ test('external lockfile: peer dependency is grouped with dependent even after a
|
||||
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/peer-c@1.0.0', '@pnpm.e2e/abc-parent-with-ab@1.0.0'], testDefaults({ lockfileDir, strictPeerDependencies: false }))
|
||||
|
||||
{
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers._).toStrictEqual({
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers?._).toStrictEqual({
|
||||
dependencies: {
|
||||
'@pnpm.e2e/abc-parent-with-ab': {
|
||||
specifier: '1.0.0',
|
||||
@@ -889,8 +889,8 @@ test('external lockfile: peer dependency is grouped with dependent even after a
|
||||
await addDependenciesToPackage(manifest, ['@pnpm.e2e/peer-c@2.0.0'], testDefaults({ lockfileDir, strictPeerDependencies: false }))
|
||||
|
||||
{
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers._).toStrictEqual({
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
expect(lockfile.importers?._).toStrictEqual({
|
||||
dependencies: {
|
||||
'@pnpm.e2e/abc-parent-with-ab': {
|
||||
specifier: '1.0.0',
|
||||
@@ -936,7 +936,7 @@ test('peer dependency is resolved from parent package', async () => {
|
||||
rootDir: path.resolve('pkg') as ProjectRootDir,
|
||||
}, testDefaults())
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(WANTED_LOCKFILE)
|
||||
const lockfile = readYamlFile<LockfileFile>(WANTED_LOCKFILE)
|
||||
expect(Object.keys(lockfile.snapshots ?? {}).sort()).toStrictEqual([
|
||||
'@pnpm.e2e/has-tango-as-peer-dep@1.0.0(@pnpm.e2e/tango@1.0.0)',
|
||||
'@pnpm.e2e/tango@1.0.0',
|
||||
@@ -963,7 +963,7 @@ test('transitive peerDependencies field does not break the lockfile on subsequen
|
||||
rootDir: path.resolve('pkg') as ProjectRootDir,
|
||||
}, testDefaults())
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(WANTED_LOCKFILE)
|
||||
const lockfile = readYamlFile<LockfileFile>(WANTED_LOCKFILE)
|
||||
|
||||
expect(Object.keys(lockfile.snapshots!['most@1.7.3'].dependencies!)).toStrictEqual([
|
||||
'@most/multicast',
|
||||
@@ -985,7 +985,7 @@ test('peer dependency is resolved from parent package via its alias', async () =
|
||||
rootDir: path.resolve('pkg') as ProjectRootDir,
|
||||
}, testDefaults())
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(WANTED_LOCKFILE)
|
||||
const lockfile = readYamlFile<LockfileFile>(WANTED_LOCKFILE)
|
||||
expect(Object.keys(lockfile.snapshots ?? {}).sort()).toStrictEqual([
|
||||
'@pnpm.e2e/has-tango-as-peer-dep@1.0.0(@pnpm.e2e/tango-tango@1.0.0)',
|
||||
'@pnpm.e2e/tango-tango@1.0.0(@pnpm.e2e/tango-tango@1.0.0)',
|
||||
@@ -1282,7 +1282,7 @@ test('peer dependency is grouped with dependency when peer is resolved not from
|
||||
]
|
||||
await mutateModules(importers, testDefaults({ allProjects }))
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve(WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve(WANTED_LOCKFILE))
|
||||
expect(lockfile.snapshots?.['ajv-keywords@1.5.0(ajv@ajv)'].dependencies?.['ajv']).toBe('link:ajv')
|
||||
})
|
||||
|
||||
@@ -1296,7 +1296,7 @@ test('deduplicate packages that have optional and non-optional peers', async ()
|
||||
testDefaults({ autoInstallPeers: false, dedupePeerDependents: true })
|
||||
)
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve(WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve(WANTED_LOCKFILE))
|
||||
const depPaths = Object.keys(lockfile.snapshots ?? {})
|
||||
expect(depPaths.length).toBe(5)
|
||||
expect(depPaths).toContain(`@pnpm.e2e/abc-optional-peers@1.0.0${createPeersDirSuffix([{ name: '@pnpm.e2e/peer-a', version: '1.0.0' }, { name: '@pnpm.e2e/peer-b', version: '1.0.0' }, { name: '@pnpm.e2e/peer-c', version: '1.0.0' }])}`)
|
||||
@@ -1314,7 +1314,7 @@ test('deduplicate packages that have peers', async () => {
|
||||
testDefaults({ autoInstallPeers: false, dedupePeerDependents: true })
|
||||
)
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve(WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve(WANTED_LOCKFILE))
|
||||
const depPaths = Object.keys(lockfile.snapshots ?? {})
|
||||
expect(depPaths.length).toBe(8)
|
||||
expect(depPaths).toContain(`@pnpm.e2e/abc@1.0.0${createPeersDirSuffix([{ name: '@pnpm.e2e/peer-a', version: '1.0.0' }, { name: '@pnpm.e2e/peer-b', version: '1.0.0' }, { name: '@pnpm.e2e/peer-c', version: '1.0.0' }])}`)
|
||||
@@ -1378,7 +1378,7 @@ test('deduplicate packages that have peers, when adding new dependency in a work
|
||||
}
|
||||
await mutateModules(importers, testDefaults({ allProjects, autoInstallPeers: false, dedupePeerDependents: true }))
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve(WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve(WANTED_LOCKFILE))
|
||||
const depPaths = Object.keys(lockfile.snapshots ?? {})
|
||||
expect(depPaths.length).toBe(8)
|
||||
expect(depPaths).toContain(`@pnpm.e2e/abc@1.0.0${createPeersDirSuffix([{ name: '@pnpm.e2e/peer-a', version: '1.0.0' }, { name: '@pnpm.e2e/peer-b', version: '1.0.0' }, { name: '@pnpm.e2e/peer-c', version: '1.0.0' }])}`)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from 'path'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { type LockfileV9 as Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.fs'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { addDistTag } from '@pnpm/registry-mock'
|
||||
import { sync as readYamlFile } from 'read-yaml-file'
|
||||
@@ -110,7 +110,7 @@ test('update dependency when external lockfile directory is used', async () => {
|
||||
|
||||
await install(manifest, testDefaults({ update: true, depth: 0, lockfileDir }))
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(path.join('..', WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileFile>(path.join('..', WANTED_LOCKFILE))
|
||||
|
||||
expect(lockfile.packages).toHaveProperty(['@pnpm.e2e/foo@100.1.0'])
|
||||
})
|
||||
|
||||
@@ -164,7 +164,7 @@ test('dependency should be removed from the old field when installing it as a di
|
||||
{
|
||||
const lockfile = project.readCurrentLockfile()
|
||||
expect(Object.keys(lockfile.importers['.'].devDependencies ?? {})).toStrictEqual(['@pnpm.e2e/bar', '@pnpm.e2e/foo', '@pnpm.e2e/qar'])
|
||||
expect(lockfile.dependencies).toBeFalsy()
|
||||
expect(lockfile.importers['.'].dependencies).toBeFalsy()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { type RootLog } from '@pnpm/core-loggers'
|
||||
import { type PnpmError } from '@pnpm/error'
|
||||
import { fixtures } from '@pnpm/test-fixtures'
|
||||
import { type Lockfile, type TarballResolution } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileFileV9 } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject, type TarballResolution } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { tempDir, prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { readPackageJsonFromDir } from '@pnpm/read-package-json'
|
||||
import { addDistTag, getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
@@ -93,10 +93,14 @@ test('lockfile with scoped package', async () => {
|
||||
prepareEmpty()
|
||||
|
||||
writeYamlFile(WANTED_LOCKFILE, {
|
||||
dependencies: {
|
||||
'@types/semver': {
|
||||
specifier: '^5.3.31',
|
||||
version: '5.3.31',
|
||||
importers: {
|
||||
'.': {
|
||||
dependencies: {
|
||||
'@types/semver': {
|
||||
specifier: '^5.3.31',
|
||||
version: '5.3.31',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
lockfileVersion: LOCKFILE_VERSION,
|
||||
@@ -824,7 +828,7 @@ test('lockfile file has correct format when lockfile directory does not equal th
|
||||
expect(modules.pendingBuilds.length).toBe(0)
|
||||
|
||||
{
|
||||
const lockfile: LockfileFileV9 = readYamlFile(WANTED_LOCKFILE)
|
||||
const lockfile: LockfileFile = readYamlFile(WANTED_LOCKFILE)
|
||||
const id = '@pnpm.e2e/pkg-with-1-dep@100.0.0'
|
||||
|
||||
expect(lockfile.lockfileVersion).toBe(LOCKFILE_VERSION)
|
||||
@@ -856,7 +860,7 @@ test('lockfile file has correct format when lockfile directory does not equal th
|
||||
}))
|
||||
|
||||
{
|
||||
const lockfile = readYamlFile<LockfileFileV9>(path.join('..', WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileFile>(path.join('..', WANTED_LOCKFILE))
|
||||
|
||||
expect(lockfile.importers).toHaveProperty(['project-2'])
|
||||
|
||||
@@ -942,7 +946,7 @@ test(`doing named installation when shared ${WANTED_LOCKFILE} exists already`, a
|
||||
})
|
||||
)
|
||||
|
||||
const currentLockfile = readYamlFile<LockfileFileV9>(path.resolve('node_modules/.pnpm/lock.yaml'))
|
||||
const currentLockfile = readYamlFile<LockfileFile>(path.resolve('node_modules/.pnpm/lock.yaml'))
|
||||
|
||||
expect(Object.keys(currentLockfile.importers ?? {})).toStrictEqual(['pkg2'])
|
||||
|
||||
@@ -1382,7 +1386,7 @@ test('a broken lockfile should not break the store', async () => {
|
||||
|
||||
const manifest = await addDependenciesToPackage({}, ['is-positive@1.0.0'], { ...opts, lockfileOnly: true })
|
||||
|
||||
const lockfile: Lockfile = readYamlFile(WANTED_LOCKFILE)
|
||||
const lockfile: LockfileObject = readYamlFile(WANTED_LOCKFILE)
|
||||
lockfile.packages!['is-positive@1.0.0' as DepPath].name = 'bad-name'
|
||||
lockfile.packages!['is-positive@1.0.0' as DepPath].version = '1.0.0'
|
||||
|
||||
@@ -1495,7 +1499,7 @@ test('update the lockfile when a new project is added to the workspace', async (
|
||||
})
|
||||
await mutateModules(importers, testDefaults({ allProjects }))
|
||||
|
||||
const lockfile: Lockfile = readYamlFile(WANTED_LOCKFILE)
|
||||
const lockfile: LockfileObject = readYamlFile(WANTED_LOCKFILE)
|
||||
expect(Object.keys(lockfile.importers)).toStrictEqual(['project-1', 'project-2'])
|
||||
})
|
||||
|
||||
@@ -1543,7 +1547,7 @@ test('update the lockfile when a new project is added to the workspace and lockf
|
||||
})
|
||||
await mutateModules(importers, testDefaults({ allProjects, lockfileOnly: true }))
|
||||
|
||||
const lockfile: Lockfile = readYamlFile(WANTED_LOCKFILE)
|
||||
const lockfile: LockfileObject = readYamlFile(WANTED_LOCKFILE)
|
||||
expect(Object.keys(lockfile.importers)).toStrictEqual(['project-1', 'project-2'])
|
||||
})
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
type RootLog,
|
||||
type StatsLog,
|
||||
} from '@pnpm/core-loggers'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { fixtures } from '@pnpm/test-fixtures'
|
||||
@@ -300,7 +300,7 @@ test('uninstalling a dependency from package that uses shared lockfile', async (
|
||||
projects['project-1'].hasNot('is-positive')
|
||||
projects['project-2'].has('is-negative')
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(WANTED_LOCKFILE)
|
||||
const lockfile = readYamlFile<LockfileObject>(WANTED_LOCKFILE)
|
||||
|
||||
expect(lockfile).toStrictEqual({
|
||||
settings: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { promises as fs } from 'fs'
|
||||
import path from 'path'
|
||||
import { contextLogger, packageManifestLogger } from '@pnpm/core-loggers'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import {
|
||||
type IncludedDependencies,
|
||||
type Modules,
|
||||
@@ -28,7 +28,7 @@ import { readLockfiles } from './readLockfiles'
|
||||
* mutating the modules directory only or in a manner that does not influence dependency resolution.
|
||||
*/
|
||||
export interface PnpmContext {
|
||||
currentLockfile: Lockfile
|
||||
currentLockfile: LockfileObject
|
||||
currentLockfileIsUpToDate: boolean
|
||||
existsCurrentLockfile: boolean
|
||||
existsWantedLockfile: boolean
|
||||
@@ -61,7 +61,7 @@ export interface PnpmContext {
|
||||
/** As applied to existing modules directory, if it exists. */
|
||||
skipped: Set<DepPath>
|
||||
storeDir: string
|
||||
wantedLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
wantedLockfileIsModified: boolean
|
||||
workspacePackages: WorkspacePackages
|
||||
registries: Registries
|
||||
@@ -186,7 +186,7 @@ export async function getContext (
|
||||
}
|
||||
|
||||
export interface PnpmSingleContext {
|
||||
currentLockfile: Lockfile
|
||||
currentLockfile: LockfileObject
|
||||
currentLockfileIsUpToDate: boolean
|
||||
existsCurrentLockfile: boolean
|
||||
existsWantedLockfile: boolean
|
||||
@@ -214,7 +214,7 @@ export interface PnpmSingleContext {
|
||||
/** As applied to existing modules directory, if it exists. */
|
||||
skipped: Set<string>
|
||||
storeDir: string
|
||||
wantedLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
wantedLockfileIsModified: boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
createLockfileObject,
|
||||
existsNonEmptyWantedLockfile,
|
||||
isEmptyLockfile,
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
readCurrentLockfile,
|
||||
readWantedLockfile,
|
||||
readWantedLockfileAndAutofixConflicts,
|
||||
@@ -19,11 +19,11 @@ import clone from 'ramda/src/clone'
|
||||
import equals from 'ramda/src/equals'
|
||||
|
||||
export interface PnpmContext {
|
||||
currentLockfile: Lockfile
|
||||
currentLockfile: LockfileObject
|
||||
existsCurrentLockfile: boolean
|
||||
existsWantedLockfile: boolean
|
||||
existsNonEmptyWantedLockfile: boolean
|
||||
wantedLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
}
|
||||
|
||||
export async function readLockfiles (
|
||||
@@ -45,12 +45,12 @@ export async function readLockfiles (
|
||||
virtualStoreDir: string
|
||||
}
|
||||
): Promise<{
|
||||
currentLockfile: Lockfile
|
||||
currentLockfile: LockfileObject
|
||||
currentLockfileIsUpToDate: boolean
|
||||
existsCurrentLockfile: boolean
|
||||
existsWantedLockfile: boolean
|
||||
existsNonEmptyWantedLockfile: boolean
|
||||
wantedLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
wantedLockfileIsModified: boolean
|
||||
lockfileHadConflicts: boolean
|
||||
}> {
|
||||
@@ -63,7 +63,7 @@ export async function readLockfiles (
|
||||
useGitBranchLockfile: opts.useGitBranchLockfile,
|
||||
mergeGitBranchLockfiles: opts.mergeGitBranchLockfiles,
|
||||
}
|
||||
const fileReads = [] as Array<Promise<Lockfile | undefined | null>>
|
||||
const fileReads = [] as Array<Promise<LockfileObject | undefined | null>>
|
||||
let lockfileHadConflicts: boolean = false
|
||||
if (opts.useLockfile) {
|
||||
if (!opts.frozenLockfile) {
|
||||
@@ -107,7 +107,7 @@ export async function readLockfiles (
|
||||
}
|
||||
})()
|
||||
)
|
||||
const files = await Promise.all<Lockfile | null | undefined>(fileReads)
|
||||
const files = await Promise.all<LockfileObject | null | undefined>(fileReads)
|
||||
const sopts = {
|
||||
autoInstallPeers: opts.autoInstallPeers,
|
||||
excludeLinksFromLockfile: opts.excludeLinksFromLockfile,
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
import { linkBins, linkBinsOfPackages } from '@pnpm/link-bins'
|
||||
import {
|
||||
getLockfileImporterId,
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type PatchFile,
|
||||
readCurrentLockfile,
|
||||
readWantedLockfile,
|
||||
@@ -110,7 +110,7 @@ export interface HeadlessOptions {
|
||||
onlyBuiltDependenciesFile?: string
|
||||
autoInstallPeers?: boolean
|
||||
childConcurrency?: number
|
||||
currentLockfile?: Lockfile
|
||||
currentLockfile?: LockfileObject
|
||||
currentEngine: {
|
||||
nodeVersion?: string
|
||||
pnpmVersion: string
|
||||
@@ -162,7 +162,7 @@ export interface HeadlessOptions {
|
||||
}
|
||||
pruneStore: boolean
|
||||
pruneVirtualStore?: boolean
|
||||
wantedLockfile?: Lockfile
|
||||
wantedLockfile?: LockfileObject
|
||||
ownLifecycleHooksStdio?: 'inherit' | 'pipe'
|
||||
pendingBuilds: string[]
|
||||
resolveSymlinksInInjectedDirs?: boolean
|
||||
@@ -664,7 +664,7 @@ export async function headlessInstall (opts: HeadlessOptions): Promise<Installat
|
||||
}
|
||||
|
||||
type SymlinkDirectDependenciesOpts = Pick<HeadlessOptions, 'registries' | 'symlink' | 'lockfileDir'> & {
|
||||
filteredLockfile: Lockfile
|
||||
filteredLockfile: LockfileObject
|
||||
dedupe: boolean
|
||||
directDependenciesByImporterId: DirectDependenciesByImporterId
|
||||
projects: Project[]
|
||||
@@ -741,7 +741,7 @@ async function linkBinsOfImporter (
|
||||
}
|
||||
|
||||
async function getRootPackagesToLink (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
opts: {
|
||||
registries: Registries
|
||||
projectDir: string
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import pathExists from 'path-exists'
|
||||
import path from 'path'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type PackageSnapshot,
|
||||
type PatchFile,
|
||||
type ProjectSnapshot,
|
||||
@@ -54,8 +54,8 @@ export interface LockfileToHoistedDepGraphOptions {
|
||||
}
|
||||
|
||||
export async function lockfileToHoistedDepGraph (
|
||||
lockfile: Lockfile,
|
||||
currentLockfile: Lockfile | null,
|
||||
lockfile: LockfileObject,
|
||||
currentLockfile: LockfileObject | null,
|
||||
opts: LockfileToHoistedDepGraphOptions
|
||||
): Promise<LockfileToDepGraphResult> {
|
||||
let prevGraph!: DependenciesGraph
|
||||
@@ -75,7 +75,7 @@ export async function lockfileToHoistedDepGraph (
|
||||
}
|
||||
|
||||
async function _lockfileToHoistedDepGraph (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
opts: LockfileToHoistedDepGraphOptions
|
||||
): Promise<Omit<LockfileToDepGraphResult, 'prevGraph'>> {
|
||||
const tree = hoist(lockfile, {
|
||||
@@ -157,7 +157,7 @@ function pickLinkedDirectDeps (
|
||||
async function fetchDeps (
|
||||
opts: {
|
||||
graph: DependenciesGraph
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
pkgLocationsByDepPath: Record<string, string[]>
|
||||
hoistedLocations: Record<string, string[]>
|
||||
} & LockfileToHoistedDepGraphOptions,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { linkLogger } from '@pnpm/core-loggers'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { linkBinsOfPkgsByAliases, type WarnFunction } from '@pnpm/link-bins'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
nameVerFromPkgSnapshot,
|
||||
} from '@pnpm/lockfile.utils'
|
||||
import { lockfileWalker, type LockfileWalkerStep } from '@pnpm/lockfile.walker'
|
||||
@@ -56,7 +56,7 @@ export async function hoist (opts: HoistOpts): Promise<HoistedDependencies> {
|
||||
}
|
||||
|
||||
export interface GetHoistedDependenciesOpts {
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
importerIds?: ProjectId[]
|
||||
privateHoistPattern: string[]
|
||||
privateHoistedModulesDir: string
|
||||
@@ -202,7 +202,7 @@ function hoistGraph (
|
||||
currentSpecifiers: Record<string, string>,
|
||||
opts: {
|
||||
getAliasHoistType: GetAliasHoistType
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
}
|
||||
): HoistGraphResult {
|
||||
const hoistedAliases = new Set(Object.keys(currentSpecifiers))
|
||||
@@ -242,7 +242,7 @@ function hoistGraph (
|
||||
async function symlinkHoistedDependencies (
|
||||
hoistedDependencies: HoistedDependencies,
|
||||
opts: {
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
privateHoistedModulesDir: string
|
||||
publicHoistedModulesDir: string
|
||||
virtualStoreDir: string
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from '@pnpm/core-loggers'
|
||||
import { filterLockfile, filterLockfileByImporters } from '@pnpm/lockfile.filtering'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type PackageSnapshots,
|
||||
type ProjectSnapshot,
|
||||
} from '@pnpm/lockfile.types'
|
||||
@@ -46,8 +46,8 @@ export async function prune (
|
||||
hoistedDependencies: HoistedDependencies
|
||||
hoistedModulesDir?: string
|
||||
publicHoistedModulesDir?: string
|
||||
wantedLockfile: Lockfile
|
||||
currentLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
currentLockfile: LockfileObject
|
||||
pruneStore?: boolean
|
||||
pruneVirtualStore?: boolean
|
||||
skipped: Set<DepPath>
|
||||
@@ -249,7 +249,7 @@ function getPkgsDepPaths (
|
||||
|
||||
function getPkgsDepPathsOwnedOnlyByImporters (
|
||||
importerIds: ProjectId[],
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
include: { [dependenciesField in DependenciesField]: boolean },
|
||||
skipped: Set<DepPath>
|
||||
): Record<string, string> {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { arrayOfWorkspacePackagesToMap } from '@pnpm/get-context'
|
||||
import { filterPkgsBySelectorObjects } from '@pnpm/filter-workspace-packages'
|
||||
import { filterDependenciesByType } from '@pnpm/manifest-utils'
|
||||
import { findWorkspacePackages } from '@pnpm/workspace.find-packages'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { rebuildProjects } from '@pnpm/plugin-commands-rebuild'
|
||||
import { createOrConnectStoreController, type CreateStoreControllerOptions } from '@pnpm/store-connection-manager'
|
||||
import { type IncludedDependencies, type Project, type ProjectsGraph, type ProjectRootDir, type PrepareExecutionEnv } from '@pnpm/types'
|
||||
@@ -118,7 +118,7 @@ export type InstallDepsOptions = Pick<Config,
|
||||
* lockfile will change on disk after installation. The lockfile arguments
|
||||
* passed to this callback should not be mutated.
|
||||
*/
|
||||
lockfileCheck?: (prev: Lockfile, next: Lockfile) => void
|
||||
lockfileCheck?: (prev: LockfileObject, next: LockfileObject) => void
|
||||
update?: boolean
|
||||
updateToLatest?: boolean
|
||||
updateMatching?: (pkgName: string) => boolean
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from 'path'
|
||||
import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { add } from '@pnpm/plugin-commands-installation'
|
||||
import { preparePackages } from '@pnpm/prepare'
|
||||
import { type ProjectId } from '@pnpm/types'
|
||||
@@ -160,7 +160,7 @@ test('recursive add --save-dev, --save-peer on workspace with single lockfile',
|
||||
)
|
||||
}
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>('./pnpm-lock.yaml')
|
||||
const lockfile = readYamlFile<LockfileObject>('./pnpm-lock.yaml')
|
||||
expect(
|
||||
lockfile.importers['project-1' as ProjectId].devDependencies
|
||||
).toStrictEqual(
|
||||
|
||||
@@ -2,7 +2,7 @@ import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { DedupeCheckIssuesError } from '@pnpm/dedupe.check'
|
||||
import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { dedupe, install } from '@pnpm/plugin-commands-installation'
|
||||
import { prepare } from '@pnpm/prepare'
|
||||
import { fixtures } from '@pnpm/test-fixtures'
|
||||
@@ -157,7 +157,7 @@ async function testFixture (fixtureName: string) {
|
||||
resolutionMode: 'highest' as const, // TODO: this should work with the default resolution mode (TODOv8)
|
||||
}
|
||||
|
||||
const readProjectLockfile = () => readYamlFile<Lockfile>(path.join(project.dir(), './pnpm-lock.yaml'))
|
||||
const readProjectLockfile = () => readYamlFile<LockfileObject>(path.join(project.dir(), './pnpm-lock.yaml'))
|
||||
|
||||
const originalLockfile = readProjectLockfile()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from 'path'
|
||||
import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { add, install, update } from '@pnpm/plugin-commands-installation'
|
||||
import { prepare, preparePackages } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT, addDistTag } from '@pnpm/registry-mock'
|
||||
@@ -266,7 +266,7 @@ test('interactive update of dev dependencies only', async () => {
|
||||
workspaceDir: process.cwd(),
|
||||
})
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>('pnpm-lock.yaml')
|
||||
const lockfile = readYamlFile<LockfileObject>('pnpm-lock.yaml')
|
||||
|
||||
expect(Object.keys(lockfile.packages ?? {})).toStrictEqual([
|
||||
'is-negative@1.0.1',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type PnpmError } from '@pnpm/error'
|
||||
import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { readModulesManifest } from '@pnpm/modules-yaml'
|
||||
import { install, update } from '@pnpm/plugin-commands-installation'
|
||||
import { preparePackages } from '@pnpm/prepare'
|
||||
@@ -109,7 +109,7 @@ test('recursive update prod dependencies only', async () => {
|
||||
workspaceDir: process.cwd(),
|
||||
})
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>('./pnpm-lock.yaml')
|
||||
const lockfile = readYamlFile<LockfileObject>('./pnpm-lock.yaml')
|
||||
expect(
|
||||
Object.keys(lockfile.packages ?? {})
|
||||
).toStrictEqual(
|
||||
@@ -314,7 +314,7 @@ test('recursive update --latest foo should only update projects that have foo',
|
||||
workspaceDir: process.cwd(),
|
||||
}, ['@zkochan/async-regex-replace', '@pnpm.e2e/foo'])
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>('./pnpm-lock.yaml')
|
||||
const lockfile = readYamlFile<LockfileObject>('./pnpm-lock.yaml')
|
||||
|
||||
expect(Object.keys(lockfile.packages ?? {}).sort()).toStrictEqual([
|
||||
'@zkochan/async-regex-replace@0.2.0',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LockfileMissingDependencyError } from '@pnpm/error'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type ProjectId,
|
||||
nameVerFromPkgSnapshot,
|
||||
} from '@pnpm/lockfile.utils'
|
||||
@@ -12,7 +12,7 @@ export type HoistingLimits = Map<string, Set<string>>
|
||||
export type { HoisterResult }
|
||||
|
||||
export function hoist (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
opts?: {
|
||||
hoistingLimits?: HoistingLimits
|
||||
// This option was added for Bit CLI in order to prevent pnpm from overwriting dependencies linked by Bit.
|
||||
@@ -80,7 +80,7 @@ function toTree (
|
||||
{ nodes, lockfile, depPathByPkgId, autoInstallPeers }: {
|
||||
autoInstallPeers?: boolean
|
||||
depPathByPkgId: Map<string, string>
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
nodes: Map<string, HoisterTree>
|
||||
},
|
||||
deps: Record<string, string>
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
} from '@pnpm/core-loggers'
|
||||
import { globalWarn } from '@pnpm/logger'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type ProjectSnapshot,
|
||||
} from '@pnpm/lockfile.types'
|
||||
import {
|
||||
@@ -99,7 +99,7 @@ export interface ResolveDependenciesResult {
|
||||
[pkgId: string]: string
|
||||
}
|
||||
linkedDependenciesByProjectId: Record<string, LinkedDependency[]>
|
||||
newLockfile: Lockfile
|
||||
newLockfile: LockfileObject
|
||||
peerDependencyIssuesByProjects: PeerDependencyIssuesByProjects
|
||||
waitTillAllFetchingsFinish: () => Promise<void>
|
||||
wantedToBeSkippedPackageIds: Set<string>
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '@pnpm/core-loggers'
|
||||
import { PnpmError } from '@pnpm/error'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type PackageSnapshot,
|
||||
type ResolvedDependencies,
|
||||
} from '@pnpm/lockfile.types'
|
||||
@@ -151,8 +151,8 @@ export interface ResolutionContext {
|
||||
childrenByParentId: ChildrenByParentId
|
||||
patchedDependencies?: Record<string, PatchFile>
|
||||
pendingNodes: PendingNode[]
|
||||
wantedLockfile: Lockfile
|
||||
currentLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
currentLockfile: LockfileObject
|
||||
injectWorkspacePackages?: boolean
|
||||
linkWorkspacePackagesDepth: number
|
||||
lockfileDir: string
|
||||
@@ -995,7 +995,7 @@ async function resolveChildren (
|
||||
|
||||
function getDepsToResolve (
|
||||
wantedDependencies: Array<WantedDependency & { updateDepth?: number }>,
|
||||
wantedLockfile: Lockfile,
|
||||
wantedLockfile: LockfileObject,
|
||||
options: {
|
||||
preferredDependencies?: ResolvedDependencies
|
||||
prefix: string
|
||||
@@ -1070,7 +1070,7 @@ function getDepsToResolve (
|
||||
|
||||
function referenceSatisfiesWantedSpec (
|
||||
opts: {
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
prefix: string
|
||||
},
|
||||
wantedDep: { alias: string, pref: string },
|
||||
@@ -1107,7 +1107,7 @@ type InfoFromLockfile = {
|
||||
} | unknown)
|
||||
|
||||
function getInfoFromLockfile (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
registries: Registries,
|
||||
reference: string | undefined,
|
||||
alias: string | undefined
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { resolveFromCatalog } from '@pnpm/catalogs.resolver'
|
||||
import { type Catalogs } from '@pnpm/catalogs.types'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { type PatchFile } from '@pnpm/patching.types'
|
||||
import { type PreferredVersions, type Resolution, type WorkspacePackages } from '@pnpm/resolver-base'
|
||||
import { type StoreController } from '@pnpm/store-controller-types'
|
||||
@@ -100,7 +100,7 @@ export interface ResolveDependenciesOptions {
|
||||
allowedDeprecatedVersions: AllowedDeprecatedVersions
|
||||
allowNonAppliedPatches: boolean
|
||||
catalogs?: Catalogs
|
||||
currentLockfile: Lockfile
|
||||
currentLockfile: LockfileObject
|
||||
dedupePeerDependents?: boolean
|
||||
dryRun: boolean
|
||||
engineStrict: boolean
|
||||
@@ -125,7 +125,7 @@ export interface ResolveDependenciesOptions {
|
||||
tag: string
|
||||
virtualStoreDir: string
|
||||
virtualStoreDirMaxLength: number
|
||||
wantedLockfile: Lockfile
|
||||
wantedLockfile: LockfileObject
|
||||
workspacePackages: WorkspacePackages
|
||||
supportedArchitectures?: SupportedArchitectures
|
||||
updateToLatest?: boolean
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { logger } from '@pnpm/logger'
|
||||
import {
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type LockfileResolution,
|
||||
type PackageSnapshot,
|
||||
pruneSharedLockfile,
|
||||
@@ -18,12 +18,12 @@ import { type DependenciesGraph } from '.'
|
||||
export function updateLockfile (
|
||||
{ dependenciesGraph, lockfile, prefix, registries, lockfileIncludeTarballUrl }: {
|
||||
dependenciesGraph: DependenciesGraph
|
||||
lockfile: Lockfile
|
||||
lockfile: LockfileObject
|
||||
prefix: string
|
||||
registries: Registries
|
||||
lockfileIncludeTarballUrl?: boolean
|
||||
}
|
||||
): Lockfile {
|
||||
): LockfileObject {
|
||||
lockfile.packages = lockfile.packages ?? {}
|
||||
for (const [depPath, depNode] of Object.entries(dependenciesGraph)) {
|
||||
const [updatedOptionalDeps, updatedDeps] = partition(
|
||||
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -3129,9 +3129,6 @@ importers:
|
||||
'@pnpm/error':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/error
|
||||
'@pnpm/git-resolver':
|
||||
specifier: workspace:*
|
||||
version: link:../../resolving/git-resolver
|
||||
'@pnpm/git-utils':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/git-utils
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { type LockfileV9 as Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { prepare, preparePackages } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { sync as readYamlFile } from 'read-yaml-file'
|
||||
@@ -248,7 +248,7 @@ test('readPackage hook from pnpmfile at root of workspace', async () => {
|
||||
|
||||
process.chdir('..')
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>('pnpm-lock.yaml')
|
||||
const lockfile = readYamlFile<LockfileFile>('pnpm-lock.yaml')
|
||||
expect(lockfile.snapshots!['is-positive@1.0.0'].dependencies).toStrictEqual({
|
||||
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.1.0',
|
||||
})
|
||||
@@ -612,7 +612,7 @@ test('readPackage hook is used during removal inside a workspace', async () => {
|
||||
await execPnpm(['uninstall', 'is-positive', '--no-strict-peer-dependencies'])
|
||||
|
||||
process.chdir('..')
|
||||
const lockfile = readYamlFile<Lockfile>('pnpm-lock.yaml')
|
||||
const lockfile = readYamlFile<LockfileFile>('pnpm-lock.yaml')
|
||||
expect(lockfile.packages!['@pnpm.e2e/abc@1.0.0'].peerDependencies!['is-negative']).toBe('1.0.0')
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { STORE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { type Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.types'
|
||||
import { prepare, prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { readPackageJsonFromDir } from '@pnpm/read-package-json'
|
||||
import { readProjectManifest } from '@pnpm/read-project-manifest'
|
||||
@@ -105,7 +105,7 @@ test('install with external lockfile directory', async () => {
|
||||
|
||||
project.has('is-positive')
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileObject>(path.resolve('..', WANTED_LOCKFILE))
|
||||
|
||||
expect(Object.keys(lockfile.importers)).toStrictEqual(['project'])
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { type LockfileV9 as Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { preparePackages } from '@pnpm/prepare'
|
||||
import { addDistTag } from '@pnpm/registry-mock'
|
||||
import { sync as readYamlFile } from 'read-yaml-file'
|
||||
@@ -41,7 +41,7 @@ auto-install-peers=false`, 'utf8')
|
||||
await execPnpm(['install'])
|
||||
await execPnpm(['--filter=project-2', 'add', '@pnpm.e2e/abc@1.0.0'])
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(path.resolve(WANTED_LOCKFILE))
|
||||
const lockfile = readYamlFile<LockfileFile>(path.resolve(WANTED_LOCKFILE))
|
||||
const depPaths = Object.keys(lockfile.snapshots ?? {})
|
||||
expect(depPaths.length).toBe(8)
|
||||
expect(depPaths).toContain(`@pnpm.e2e/abc@1.0.0${createPeersDirSuffix([{ name: '@pnpm.e2e/peer-a', version: '1.0.0' }, { name: '@pnpm.e2e/peer-b', version: '1.0.0' }, { name: '@pnpm.e2e/peer-c', version: '1.0.0' }])}`)
|
||||
|
||||
@@ -3,7 +3,7 @@ import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { findWorkspacePackages } from '@pnpm/workspace.find-packages'
|
||||
import { type LockfileFileV9 as LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { readModulesManifest } from '@pnpm/modules-yaml'
|
||||
import {
|
||||
prepare,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from 'fs'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { type LockfileV9 as Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { preparePackages } from '@pnpm/prepare'
|
||||
import { sync as readYamlFile } from 'read-yaml-file'
|
||||
import { sync as writeYamlFile } from 'write-yaml-file'
|
||||
@@ -30,6 +30,6 @@ test('peer dependency is not unlinked when adding a new dependency', async () =>
|
||||
await execPnpm(['install'])
|
||||
await execPnpm(['--filter=project-1', 'add', 'is-odd@1.0.0'])
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>(WANTED_LOCKFILE)
|
||||
const lockfile = readYamlFile<LockfileFile>(WANTED_LOCKFILE)
|
||||
expect(Object.keys(lockfile!.snapshots!)).toContain('@pnpm.e2e/abc@1.0.0(@pnpm.e2e/peer-a@@pnpm.e2e+peer-a)')
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { STORE_VERSION } from '@pnpm/constants'
|
||||
import { prepare, preparePackages } from '@pnpm/prepare'
|
||||
import { type LockfileV9 as Lockfile } from '@pnpm/lockfile.types'
|
||||
import { type LockfileFile } from '@pnpm/lockfile.types'
|
||||
import { sync as readYamlFile } from 'read-yaml-file'
|
||||
import { isCI } from 'ci-info'
|
||||
import isWindows from 'is-windows'
|
||||
@@ -228,7 +228,7 @@ test('recursive installation of packages in workspace ignores hooks in packages'
|
||||
|
||||
await execPnpm(['install'])
|
||||
|
||||
const lockfile = readYamlFile<Lockfile>('pnpm-lock.yaml')
|
||||
const lockfile = readYamlFile<LockfileFile>('pnpm-lock.yaml')
|
||||
const depPaths = Object.keys(lockfile.snapshots ?? {})
|
||||
expect(depPaths).not.toContain('@pnpm.e2e/dep-of-pkg-with-1-dep@100.1.0')
|
||||
expect(depPaths).toContain('is-number@1.0.0')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import path from 'path'
|
||||
import {
|
||||
getLockfileImporterId,
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type ProjectSnapshot,
|
||||
readCurrentLockfile,
|
||||
readWantedLockfile,
|
||||
@@ -100,8 +100,8 @@ export async function buildDependenciesHierarchy (
|
||||
|
||||
async function dependenciesHierarchyForPackage (
|
||||
projectPath: string,
|
||||
currentLockfile: Lockfile,
|
||||
wantedLockfile: Lockfile | null,
|
||||
currentLockfile: LockfileObject,
|
||||
wantedLockfile: LockfileObject | null,
|
||||
opts: {
|
||||
depth: number
|
||||
excludePeerDependencies?: boolean
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PnpmError } from '@pnpm/error'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import { detectDepTypes } from '@pnpm/lockfile.detect-dep-types'
|
||||
import {
|
||||
type SupportedArchitectures,
|
||||
@@ -77,7 +77,7 @@ export async function findDependencyLicenses (opts: {
|
||||
virtualStoreDirMaxLength: number
|
||||
modulesDir?: string
|
||||
registries: Registries
|
||||
wantedLockfile: Lockfile | null
|
||||
wantedLockfile: LockfileObject | null
|
||||
includedImporterIds?: ProjectId[]
|
||||
supportedArchitectures?: SupportedArchitectures
|
||||
}): Promise<LicensePackage[]> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Lockfile, type TarballResolution } from '@pnpm/lockfile.types'
|
||||
import { type LockfileObject, type TarballResolution } from '@pnpm/lockfile.types'
|
||||
import { nameVerFromPkgSnapshot } from '@pnpm/lockfile.utils'
|
||||
import { packageIsInstallable } from '@pnpm/package-is-installable'
|
||||
import {
|
||||
@@ -124,7 +124,7 @@ export async function lockfileToLicenseNode (
|
||||
* @returns
|
||||
*/
|
||||
export async function lockfileToLicenseNodeTree (
|
||||
lockfile: Lockfile,
|
||||
lockfile: LockfileObject,
|
||||
opts: {
|
||||
include?: { [dependenciesField in DependenciesField]: boolean }
|
||||
includedImporterIds?: ProjectId[]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { findDependencyLicenses } from '@pnpm/license-scanner'
|
||||
import { LOCKFILE_VERSION } from '@pnpm/constants'
|
||||
import { type DepPath, type ProjectManifest, type Registries, type ProjectId } from '@pnpm/types'
|
||||
import { type Lockfile } from '@pnpm/lockfile.fs'
|
||||
import { type LockfileObject } from '@pnpm/lockfile.fs'
|
||||
import { type LicensePackage } from '../lib/licenses'
|
||||
import { type GetPackageInfoOptions, type PackageInfo } from '../lib/getPkgInfo'
|
||||
|
||||
@@ -35,7 +35,7 @@ jest.mock('../lib/getPkgInfo', () => {
|
||||
|
||||
describe('licences', () => {
|
||||
test('findDependencyLicenses()', async () => {
|
||||
const lockfile: Lockfile = {
|
||||
const lockfile: LockfileObject = {
|
||||
importers: {
|
||||
['.' as ProjectId]: {
|
||||
dependencies: {
|
||||
@@ -103,7 +103,7 @@ describe('licences', () => {
|
||||
})
|
||||
|
||||
test('filterable by includedImporterIds', async () => {
|
||||
const lockfile: Lockfile = {
|
||||
const lockfile: LockfileObject = {
|
||||
importers: {
|
||||
['.' as ProjectId]: {
|
||||
dependencies: {
|
||||
@@ -178,7 +178,7 @@ describe('licences', () => {
|
||||
})
|
||||
|
||||
test('findDependencyLicenses lists all versions (#7724)', async () => {
|
||||
const lockfile: Lockfile = {
|
||||
const lockfile: LockfileObject = {
|
||||
importers: {
|
||||
['.' as ProjectId]: {
|
||||
dependencies: {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { PnpmError } from '@pnpm/error'
|
||||
import {
|
||||
getLockfileImporterId,
|
||||
type Lockfile,
|
||||
type LockfileObject,
|
||||
type ProjectSnapshot,
|
||||
} from '@pnpm/lockfile.fs'
|
||||
import { nameVerFromPkgSnapshot } from '@pnpm/lockfile.utils'
|
||||
@@ -48,7 +48,7 @@ export async function outdated (
|
||||
opts: {
|
||||
catalogs?: Catalogs
|
||||
compatible?: boolean
|
||||
currentLockfile: Lockfile | null
|
||||
currentLockfile: LockfileObject | null
|
||||
getLatestManifest: GetLatestManifestFunction
|
||||
ignoreDependencies?: string[]
|
||||
include?: IncludedDependencies
|
||||
@@ -57,7 +57,7 @@ export async function outdated (
|
||||
match?: (dependencyName: string) => boolean
|
||||
prefix: string
|
||||
registries: Registries
|
||||
wantedLockfile: Lockfile | null
|
||||
wantedLockfile: LockfileObject | null
|
||||
}
|
||||
): Promise<OutdatedPackage[]> {
|
||||
if (packageHasNoDeps(opts.manifest)) return []
|
||||
@@ -81,7 +81,7 @@ export async function outdated (
|
||||
|
||||
const allDeps = getAllDependenciesFromManifest(await getOverriddenManifest())
|
||||
const importerId = getLockfileImporterId(opts.lockfileDir, opts.prefix)
|
||||
const currentLockfile: Lockfile = opts.currentLockfile ?? { lockfileVersion: LOCKFILE_VERSION, importers: { [importerId]: { specifiers: {} } } }
|
||||
const currentLockfile: LockfileObject = opts.currentLockfile ?? { lockfileVersion: LOCKFILE_VERSION, importers: { [importerId]: { specifiers: {} } } }
|
||||
|
||||
const outdated: OutdatedPackage[] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user