refactor: create @pnpm/lockfile.verification (#8350)

This commit is contained in:
Zoltan Kochan
2024-07-27 14:18:38 +02:00
committed by GitHub
parent 1b349deba5
commit 2e3eae3990
18 changed files with 232 additions and 22 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/lockfile.verification": major
---
Initial release.

View File

@@ -5,7 +5,6 @@ export { nameVerFromPkgSnapshot } from './nameVerFromPkgSnapshot'
export { packageIdFromSnapshot } from './packageIdFromSnapshot'
export { packageIsIndependent } from './packageIsIndependent'
export { pkgSnapshotToResolution } from './pkgSnapshotToResolution'
export { satisfiesPackageManifest } from './satisfiesPackageManifest'
export { refIsLocalTarball, refIsLocalDirectory } from './refIsLocalTarball'
export * from '@pnpm/lockfile-types'

View File

@@ -0,0 +1,15 @@
# @pnpm/lockfile.verification
> Checks a lockfile
[![npm version](https://img.shields.io/npm/v/@pnpm/lockfile.verification.svg)](https://www.npmjs.com/package/@pnpm/lockfile.verification)
## Installation
```sh
pnpm add @pnpm/lockfile.verification
```
## License
MIT

View File

@@ -0,0 +1,3 @@
const config = require('../../jest.config.js');
module.exports = Object.assign({}, config, {});

View File

@@ -0,0 +1,60 @@
{
"name": "@pnpm/lockfile.verification",
"version": "0.0.0",
"description": "Checks a lockfile",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib",
"!*.map"
],
"engines": {
"node": ">=18.12"
},
"scripts": {
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
"_test": "jest",
"test": "pnpm run compile && pnpm run _test",
"prepublishOnly": "pnpm run compile",
"compile": "tsc --build && pnpm run lint --fix"
},
"repository": "https://github.com/pnpm/pnpm/blob/main/lockfile/verification",
"keywords": [
"pnpm9",
"pnpm",
"lockfile"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/pnpm/pnpm/issues"
},
"homepage": "https://github.com/pnpm/pnpm/blob/main/lockfile/verification#readme",
"peerDependencies": {
"@pnpm/logger": "^5.0.0"
},
"dependencies": {
"@pnpm/catalogs.types": "workspace:*",
"@pnpm/dependency-path": "workspace:*",
"@pnpm/get-context": "workspace:*",
"@pnpm/lockfile-utils": "workspace:*",
"@pnpm/lockfile-types": "workspace:*",
"@pnpm/read-package-json": "workspace:*",
"@pnpm/resolver-base": "workspace:*",
"@pnpm/types": "workspace:*",
"p-every": "catalog:",
"ramda": "catalog:",
"semver": "catalog:",
"version-selector-type": "catalog:"
},
"devDependencies": {
"@pnpm/constants": "workspace:*",
"@pnpm/lockfile.verification": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@types/ramda": "catalog:",
"@types/semver": "catalog:"
},
"funding": "https://opencollective.com/pnpm",
"exports": {
".": "./lib/index.js"
}
}

View File

@@ -1,4 +1,4 @@
import { type CatalogSnapshots } from '@pnpm/lockfile-file'
import { type CatalogSnapshots } from '@pnpm/lockfile-types'
import { type Catalogs } from '@pnpm/catalogs.types'
export function allCatalogsAreUpToDate (

View File

@@ -6,8 +6,8 @@ import {
type Lockfile,
type ProjectSnapshot,
type PackageSnapshots,
} from '@pnpm/lockfile-file'
import { refIsLocalDirectory, refIsLocalTarball, satisfiesPackageManifest } from '@pnpm/lockfile-utils'
} from '@pnpm/lockfile-types'
import { refIsLocalDirectory, refIsLocalTarball } from '@pnpm/lockfile-utils'
import { safeReadPackageJsonFromDir } from '@pnpm/read-package-json'
import { refToRelative } from '@pnpm/dependency-path'
import { type DirectoryResolution, type WorkspacePackages } from '@pnpm/resolver-base'
@@ -23,6 +23,7 @@ import any from 'ramda/src/any'
import semver from 'semver'
import getVersionSelectorType from 'version-selector-type'
import { allCatalogsAreUpToDate } from './allCatalogsAreUpToDate'
import { satisfiesPackageManifest } from './satisfiesPackageManifest'
export async function allProjectsAreUpToDate (
projects: Array<Pick<ProjectOptions, 'manifest' | 'rootDir'> & { id: ProjectId }>,

View File

@@ -0,0 +1,2 @@
export { allProjectsAreUpToDate } from './allProjectsAreUpToDate'
export { satisfiesPackageManifest } from './satisfiesPackageManifest'

View File

@@ -1,9 +1,9 @@
import { LOCKFILE_VERSION } from '@pnpm/constants'
import { prepareEmpty } from '@pnpm/prepare'
import { type ProjectId, type ProjectRootDir } from '@pnpm/types'
import { allProjectsAreUpToDate } from '../lib/install/allProjectsAreUpToDate'
import { allProjectsAreUpToDate } from '@pnpm/lockfile.verification'
import { writeFile, mkdir } from 'fs/promises'
import { type Lockfile } from '@pnpm/lockfile-file'
import { type Lockfile } from '@pnpm/lockfile-types'
const fooManifest = {
name: 'foo',

View File

@@ -1,4 +1,4 @@
import { satisfiesPackageManifest } from '@pnpm/lockfile-utils'
import { satisfiesPackageManifest } from '@pnpm/lockfile.verification'
const DEFAULT_PKG_FIELDS = {
name: 'project',

View File

@@ -0,0 +1,17 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": false,
"noEmit": true,
"rootDir": "."
},
"include": [
"**/*.ts",
"../../../__typings__/**/*.d.ts"
],
"references": [
{
"path": ".."
}
]
}

View File

@@ -0,0 +1,43 @@
{
"extends": "@pnpm/tsconfig",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/**/*.ts",
"../../__typings__/**/*.d.ts"
],
"references": [
{
"path": "../../__utils__/prepare"
},
{
"path": "../../catalogs/types"
},
{
"path": "../../packages/constants"
},
{
"path": "../../packages/dependency-path"
},
{
"path": "../../packages/types"
},
{
"path": "../../pkg-manager/get-context"
},
{
"path": "../../pkg-manifest/read-package-json"
},
{
"path": "../../resolving/resolver-base"
},
{
"path": "../lockfile-types"
},
{
"path": "../lockfile-utils"
}
]
}

View File

@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"include": [
"src/**/*.ts",
"test/**/*.ts",
"../../__typings__/**/*.d.ts"
]
}

View File

@@ -35,6 +35,7 @@
"@pnpm/hooks.types": "workspace:*",
"@pnpm/lifecycle": "workspace:*",
"@pnpm/link-bins": "workspace:*",
"@pnpm/lockfile.verification": "workspace:*",
"@pnpm/lockfile-file": "workspace:*",
"@pnpm/lockfile-to-pnp": "workspace:*",
"@pnpm/lockfile-utils": "workspace:*",
@@ -52,7 +53,6 @@
"@pnpm/pkg-manager.direct-dep-linker": "workspace:*",
"@pnpm/prune-lockfile": "workspace:*",
"@pnpm/read-modules-dir": "workspace:*",
"@pnpm/read-package-json": "workspace:*",
"@pnpm/read-project-manifest": "workspace:*",
"@pnpm/remove-bins": "workspace:*",
"@pnpm/resolve-dependencies": "workspace:*",
@@ -66,7 +66,6 @@
"is-subdir": "catalog:",
"load-json-file": "catalog:",
"normalize-path": "catalog:",
"p-every": "catalog:",
"p-filter": "catalog:",
"p-limit": "catalog:",
"p-map-values": "catalog:",
@@ -74,8 +73,7 @@
"ramda": "catalog:",
"run-groups": "catalog:",
"semver": "catalog:",
"sort-keys": "catalog:",
"version-selector-type": "catalog:"
"sort-keys": "catalog:"
},
"devDependencies": {
"@pnpm/assert-project": "workspace:*",
@@ -87,6 +85,7 @@
"@pnpm/lockfile-types": "workspace:*",
"@pnpm/package-store": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/read-package-json": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/store-path": "workspace:*",
"@pnpm/store.cafs": "workspace:*",

View File

@@ -35,7 +35,8 @@ import {
type PatchFile,
} from '@pnpm/lockfile-file'
import { writePnpFile } from '@pnpm/lockfile-to-pnp'
import { extendProjectsWithTargetDirs, satisfiesPackageManifest } from '@pnpm/lockfile-utils'
import { extendProjectsWithTargetDirs } from '@pnpm/lockfile-utils'
import { allProjectsAreUpToDate, satisfiesPackageManifest } from '@pnpm/lockfile.verification'
import { getPreferredVersionsFromLockfileAndManifests } from '@pnpm/lockfile.preferred-versions'
import { logger, globalInfo, streamParser } from '@pnpm/logger'
import { getAllDependenciesFromManifest, getAllUniqueSpecs } from '@pnpm/manifest-utils'
@@ -80,7 +81,6 @@ import props from 'ramda/src/props'
import sortKeys from 'sort-keys'
import { parseWantedDependencies } from '../parseWantedDependencies'
import { removeDeps } from '../uninstall/removeDeps'
import { allProjectsAreUpToDate } from './allProjectsAreUpToDate'
import {
extendOptions,
type InstallOptions,

View File

@@ -87,6 +87,9 @@
{
"path": "../../lockfile/prune-lockfile"
},
{
"path": "../../lockfile/verification"
},
{
"path": "../../packages/calc-dep-state"
},

73
pnpm-lock.yaml generated
View File

@@ -3159,6 +3159,64 @@ importers:
specifier: 'catalog:'
version: 1.1.0
lockfile/verification:
dependencies:
'@pnpm/catalogs.types':
specifier: workspace:*
version: link:../../catalogs/types
'@pnpm/dependency-path':
specifier: workspace:*
version: link:../../packages/dependency-path
'@pnpm/get-context':
specifier: workspace:*
version: link:../../pkg-manager/get-context
'@pnpm/lockfile-types':
specifier: workspace:*
version: link:../lockfile-types
'@pnpm/lockfile-utils':
specifier: workspace:*
version: link:../lockfile-utils
'@pnpm/logger':
specifier: ^5.0.0
version: 5.0.0
'@pnpm/read-package-json':
specifier: workspace:*
version: link:../../pkg-manifest/read-package-json
'@pnpm/resolver-base':
specifier: workspace:*
version: link:../../resolving/resolver-base
'@pnpm/types':
specifier: workspace:*
version: link:../../packages/types
p-every:
specifier: 'catalog:'
version: 2.0.0
ramda:
specifier: 'catalog:'
version: '@pnpm/ramda@0.28.1'
semver:
specifier: 'catalog:'
version: 7.6.2
version-selector-type:
specifier: 'catalog:'
version: 3.0.0
devDependencies:
'@pnpm/constants':
specifier: workspace:*
version: link:../../packages/constants
'@pnpm/lockfile.verification':
specifier: workspace:*
version: 'link:'
'@pnpm/prepare':
specifier: workspace:*
version: link:../../__utils__/prepare
'@types/ramda':
specifier: 'catalog:'
version: 0.29.12
'@types/semver':
specifier: 'catalog:'
version: 7.5.3
modules-mounter/daemon:
dependencies:
'@pnpm/config':
@@ -3830,6 +3888,9 @@ importers:
'@pnpm/lockfile.preferred-versions':
specifier: workspace:*
version: link:../../lockfile/preferred-versions
'@pnpm/lockfile.verification':
specifier: workspace:*
version: link:../../lockfile/verification
'@pnpm/logger':
specifier: ^5.0.0
version: 5.0.0
@@ -3869,9 +3930,6 @@ importers:
'@pnpm/read-modules-dir':
specifier: workspace:*
version: link:../../fs/read-modules-dir
'@pnpm/read-package-json':
specifier: workspace:*
version: link:../../pkg-manifest/read-package-json
'@pnpm/read-project-manifest':
specifier: workspace:*
version: link:../../pkg-manifest/read-project-manifest
@@ -3914,9 +3972,6 @@ importers:
normalize-path:
specifier: 'catalog:'
version: 3.0.0
p-every:
specifier: 'catalog:'
version: 2.0.0
p-filter:
specifier: 'catalog:'
version: 2.1.0
@@ -3941,9 +3996,6 @@ importers:
sort-keys:
specifier: 'catalog:'
version: 4.2.0
version-selector-type:
specifier: 'catalog:'
version: 3.0.0
devDependencies:
'@pnpm/assert-project':
specifier: workspace:*
@@ -3972,6 +4024,9 @@ importers:
'@pnpm/prepare':
specifier: workspace:*
version: link:../../__utils__/prepare
'@pnpm/read-package-json':
specifier: workspace:*
version: link:../../pkg-manifest/read-package-json
'@pnpm/registry-mock':
specifier: 'catalog:'
version: 3.39.0(encoding@0.1.13)(typanion@3.14.0)