feat(list): update the API for usage in Bit CLI (#7132)

* feat(list): update the API for usage in Bit CLI

* refactor: move createPackagesSearcher to dependencies-hierarchy package

* docs: add changesets
This commit is contained in:
Zoltan Kochan
2023-09-26 15:23:36 +03:00
committed by GitHub
parent 546ca3f21b
commit 101c97ecb8
13 changed files with 43 additions and 27 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/reviewing.dependencies-hierarchy": minor
---
Export `createPackagesSearcher()`.

View File

@@ -0,0 +1,5 @@
---
"@pnpm/list": minor
---
Export the renderer functions.

View File

@@ -106,6 +106,7 @@ export interface BaseManifest {
keywords?: string[]
author?: string
license?: string
exports?: Record<string, string>
}
export type DependencyManifest = BaseManifest & Required<Pick<BaseManifest, 'name' | 'version'>>

24
pnpm-lock.yaml generated
View File

@@ -5053,12 +5053,18 @@ importers:
'@pnpm/lockfile-utils':
specifier: workspace:*
version: link:../../lockfile/lockfile-utils
'@pnpm/matcher':
specifier: workspace:*
version: link:../../config/matcher
'@pnpm/modules-yaml':
specifier: workspace:*
version: link:../../pkg-manager/modules-yaml
'@pnpm/normalize-registries':
specifier: workspace:*
version: link:../../config/normalize-registries
'@pnpm/npm-package-arg':
specifier: ^1.0.0
version: 1.0.0
'@pnpm/read-modules-dir':
specifier: workspace:*
version: link:../../fs/read-modules-dir
@@ -5077,6 +5083,9 @@ importers:
resolve-link-target:
specifier: ^2.0.0
version: 2.0.0
semver:
specifier: ^7.5.4
version: 7.5.4
devDependencies:
'@pnpm/constants':
specifier: workspace:*
@@ -5090,6 +5099,9 @@ importers:
'@types/normalize-path':
specifier: ^3.0.0
version: 3.0.0
'@types/semver':
specifier: 7.3.13
version: 7.3.13
reviewing/license-scanner:
dependencies:
@@ -5154,12 +5166,6 @@ importers:
reviewing/list:
dependencies:
'@pnpm/matcher':
specifier: workspace:*
version: link:../../config/matcher
'@pnpm/npm-package-arg':
specifier: ^1.0.0
version: 1.0.0
'@pnpm/read-package-json':
specifier: workspace:*
version: link:../../pkg-manifest/read-package-json
@@ -5187,9 +5193,6 @@ importers:
ramda:
specifier: npm:@pnpm/ramda@0.28.1
version: /@pnpm/ramda@0.28.1
semver:
specifier: ^7.5.4
version: 7.5.4
devDependencies:
'@pnpm/list':
specifier: workspace:*
@@ -5203,9 +5206,6 @@ importers:
'@types/ramda':
specifier: 0.28.20
version: 0.28.20
'@types/semver':
specifier: 7.3.13
version: 7.3.13
reviewing/outdated:
dependencies:

View File

@@ -35,20 +35,24 @@
"@pnpm/dependency-path": "workspace:*",
"@pnpm/lockfile-file": "workspace:*",
"@pnpm/lockfile-utils": "workspace:*",
"@pnpm/matcher": "workspace:*",
"@pnpm/modules-yaml": "workspace:*",
"@pnpm/normalize-registries": "workspace:*",
"@pnpm/npm-package-arg": "^1.0.0",
"@pnpm/read-modules-dir": "workspace:*",
"@pnpm/read-package-json": "workspace:*",
"@pnpm/types": "workspace:*",
"normalize-path": "^3.0.0",
"realpath-missing": "^1.1.0",
"resolve-link-target": "^2.0.0"
"resolve-link-target": "^2.0.0",
"semver": "^7.5.4"
},
"devDependencies": {
"@pnpm/constants": "workspace:*",
"@pnpm/reviewing.dependencies-hierarchy": "workspace:*",
"@pnpm/test-fixtures": "workspace:*",
"@types/normalize-path": "^3.0.0"
"@types/normalize-path": "^3.0.0",
"@types/semver": "7.3.13"
},
"funding": "https://opencollective.com/pnpm",
"exports": {

View File

@@ -29,7 +29,7 @@ export interface DependenciesHierarchy {
}
export async function buildDependenciesHierarchy (
projectPaths: string[],
projectPaths: string[] | undefined,
maybeOpts: {
depth: number
include?: { [dependenciesField in DependenciesField]: boolean }
@@ -51,6 +51,10 @@ export async function buildDependenciesHierarchy (
})
const currentLockfile = (modules?.virtualStoreDir && await readCurrentLockfile(modules.virtualStoreDir, { ignoreIncompatible: false })) ?? null
const wantedLockfile = await readWantedLockfile(maybeOpts.lockfileDir, { ignoreIncompatible: false })
if (projectPaths == null) {
projectPaths = Object.keys(wantedLockfile?.importers ?? {})
.map((id) => path.join(maybeOpts.lockfileDir, id))
}
const result = {} as { [projectDir: string]: DependenciesHierarchy }

View File

@@ -1,6 +1,6 @@
import { createMatcher } from '@pnpm/matcher'
import npa from '@pnpm/npm-package-arg'
import { type SearchFunction } from '@pnpm/reviewing.dependencies-hierarchy'
import { type SearchFunction } from './types'
import semver from 'semver'
export function createPackagesSearcher (queries: string[]) {

View File

@@ -1,3 +1,4 @@
export { buildDependenciesHierarchy, type DependenciesHierarchy } from './buildDependenciesHierarchy'
export { type PackageNode } from './PackageNode'
export { type SearchFunction } from './types'
export { createPackagesSearcher } from './createPackagesSearcher'

View File

@@ -12,6 +12,9 @@
{
"path": "../../__utils__/test-fixtures"
},
{
"path": "../../config/matcher"
},
{
"path": "../../config/normalize-registries"
},

View File

@@ -34,8 +34,6 @@
},
"homepage": "https://github.com/pnpm/pnpm/blob/main/reviewing/list#readme",
"dependencies": {
"@pnpm/matcher": "workspace:*",
"@pnpm/npm-package-arg": "^1.0.0",
"@pnpm/read-package-json": "workspace:*",
"@pnpm/read-project-manifest": "workspace:*",
"@pnpm/reviewing.dependencies-hierarchy": "workspace:*",
@@ -44,15 +42,13 @@
"chalk": "^4.1.2",
"cli-columns": "^4.0.0",
"p-limit": "^3.1.0",
"ramda": "npm:@pnpm/ramda@0.28.1",
"semver": "^7.5.4"
"ramda": "npm:@pnpm/ramda@0.28.1"
},
"devDependencies": {
"@pnpm/list": "workspace:*",
"@pnpm/test-fixtures": "workspace:*",
"@types/archy": "0.0.32",
"@types/ramda": "0.28.20",
"@types/semver": "7.3.13"
"@types/ramda": "0.28.20"
},
"funding": "https://opencollective.com/pnpm",
"exports": {

View File

@@ -1,14 +1,14 @@
import path from 'path'
import { safeReadProjectManifestOnly } from '@pnpm/read-project-manifest'
import { type DependenciesField, type Registries } from '@pnpm/types'
import { type PackageNode, buildDependenciesHierarchy, type DependenciesHierarchy } from '@pnpm/reviewing.dependencies-hierarchy'
import { createPackagesSearcher } from './createPackagesSearcher'
import { type PackageNode, buildDependenciesHierarchy, type DependenciesHierarchy, createPackagesSearcher } from '@pnpm/reviewing.dependencies-hierarchy'
import { renderJson } from './renderJson'
import { renderParseable } from './renderParseable'
import { renderTree } from './renderTree'
import { type PackageDependencyHierarchy } from './types'
export type { PackageNode } from '@pnpm/reviewing.dependencies-hierarchy'
export { renderJson, renderParseable, renderTree }
const DEFAULTS = {
alwaysPrintRootPackage: true,

View File

@@ -12,9 +12,6 @@
{
"path": "../../__utils__/test-fixtures"
},
{
"path": "../../config/matcher"
},
{
"path": "../../packages/types"
},