mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-23 23:29:17 -05:00
fix: import only the needed functions from ramda
This commit is contained in:
39
.changeset/pink-bags-clean.md
Normal file
39
.changeset/pink-bags-clean.md
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
"@pnpm/build-modules": patch
|
||||
"@pnpm/config": patch
|
||||
"@pnpm/default-reporter": patch
|
||||
"@pnpm/exportable-manifest": patch
|
||||
"@pnpm/filter-lockfile": patch
|
||||
"@pnpm/filter-workspace-packages": patch
|
||||
"@pnpm/get-context": patch
|
||||
"@pnpm/headless": patch
|
||||
"@pnpm/hoist": patch
|
||||
"@pnpm/link-bins": patch
|
||||
"@pnpm/list": patch
|
||||
"@pnpm/lockfile-file": patch
|
||||
"@pnpm/lockfile-to-pnp": patch
|
||||
"@pnpm/lockfile-utils": patch
|
||||
"@pnpm/lockfile-walker": patch
|
||||
"@pnpm/make-dedicated-lockfile": patch
|
||||
"@pnpm/merge-lockfile-changes": patch
|
||||
"@pnpm/modules-cleaner": patch
|
||||
"@pnpm/outdated": patch
|
||||
"@pnpm/package-requester": patch
|
||||
"pkgs-graph": patch
|
||||
"@pnpm/plugin-commands-audit": patch
|
||||
"@pnpm/plugin-commands-installation": patch
|
||||
"@pnpm/plugin-commands-listing": patch
|
||||
"@pnpm/plugin-commands-outdated": patch
|
||||
"@pnpm/plugin-commands-publishing": patch
|
||||
"@pnpm/plugin-commands-rebuild": patch
|
||||
"@pnpm/plugin-commands-script-runners": patch
|
||||
"@pnpm/plugin-commands-server": patch
|
||||
"@pnpm/plugin-commands-store": patch
|
||||
"pnpm": patch
|
||||
"@pnpm/prune-lockfile": patch
|
||||
"@pnpm/resolve-dependencies": patch
|
||||
"supi": patch
|
||||
"@pnpm/tarball-fetcher": patch
|
||||
---
|
||||
|
||||
Import only the required functions from ramda.
|
||||
@@ -9,7 +9,7 @@ import { StoreController } from '@pnpm/store-controller-types'
|
||||
import { DependencyManifest, PackageManifest } from '@pnpm/types'
|
||||
import runGroups from 'run-groups'
|
||||
import graphSequencer from 'graph-sequencer'
|
||||
import * as R from 'ramda'
|
||||
import filter from 'ramda/src/filter'
|
||||
|
||||
export default async (
|
||||
depGraph: DependenciesGraph,
|
||||
@@ -35,12 +35,12 @@ export default async (
|
||||
// postinstall hooks
|
||||
const nodesToBuild = new Set<string>()
|
||||
getSubgraphToBuild(depGraph, rootDepPaths, nodesToBuild, new Set<string>())
|
||||
const onlyFromBuildGraph = R.filter((depPath: string) => nodesToBuild.has(depPath))
|
||||
const onlyFromBuildGraph = filter((depPath: string) => nodesToBuild.has(depPath))
|
||||
|
||||
const nodesToBuildArray = Array.from(nodesToBuild)
|
||||
const graph = new Map(
|
||||
nodesToBuildArray
|
||||
.map((depPath) => [depPath, onlyFromBuildGraph(R.values(depGraph[depPath].children))])
|
||||
.map((depPath) => [depPath, onlyFromBuildGraph(Object.values(depGraph[depPath].children))])
|
||||
)
|
||||
const graphSequencerResult = graphSequencer({
|
||||
graph,
|
||||
@@ -150,7 +150,7 @@ function getSubgraphToBuild (
|
||||
}
|
||||
if (walked.has(depPath)) continue
|
||||
walked.add(depPath)
|
||||
const childShouldBeBuilt = getSubgraphToBuild(graph, R.values(graph[depPath].children), nodesToBuild, walked) ||
|
||||
const childShouldBeBuilt = getSubgraphToBuild(graph, Object.values(graph[depPath].children), nodesToBuild, walked) ||
|
||||
graph[depPath].requiresBuild
|
||||
if (childShouldBeBuilt) {
|
||||
nodesToBuild.add(depPath)
|
||||
|
||||
@@ -8,7 +8,7 @@ import camelcase from 'camelcase'
|
||||
import loadNpmConf from '@zkochan/npm-conf'
|
||||
import npmTypes from '@zkochan/npm-conf/lib/types'
|
||||
import { sync as canWriteToDir } from 'can-write-to-dir'
|
||||
import * as R from 'ramda'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import realpathMissing from 'realpath-missing'
|
||||
import whichcb from 'which'
|
||||
import getScopeRegistries, { normalizeRegistry } from './getScopeRegistries'
|
||||
@@ -207,7 +207,7 @@ export default async (
|
||||
|
||||
const rcOptions = Object.keys(rcOptionsTypes)
|
||||
|
||||
const pnpmConfig: ConfigWithDeprecatedSettings = R.fromPairs([
|
||||
const pnpmConfig: ConfigWithDeprecatedSettings = fromPairs([
|
||||
...rcOptions.map((configKey) => [camelcase(configKey), npmConfig.get(configKey)]) as any, // eslint-disable-line
|
||||
...Object.entries(cliOptions).filter(([name, value]) => typeof value !== 'undefined').map(([name, value]) => [camelcase(name), value]),
|
||||
]) as unknown as ConfigWithDeprecatedSettings
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Config } from '@pnpm/config'
|
||||
import { Log } from '@pnpm/core-loggers'
|
||||
import PnpmError from '@pnpm/error'
|
||||
import chalk from 'chalk'
|
||||
import * as R from 'ramda'
|
||||
import equals from 'ramda/src/equals'
|
||||
import StackTracey from 'stacktracey'
|
||||
import { EOL } from './constants'
|
||||
|
||||
@@ -82,7 +82,7 @@ ${formatErrorSummary(err.message)}
|
||||
|
||||
The latest release of ${meta.name} is "${meta['dist-tags'].latest}".${EOL}`
|
||||
|
||||
if (!R.equals(R.keys(meta['dist-tags']), ['latest'])) {
|
||||
if (!equals(Object.keys(meta['dist-tags']), ['latest'])) {
|
||||
output += EOL + 'Other releases are:' + EOL
|
||||
for (const tag in meta['dist-tags']) {
|
||||
if (tag !== 'latest') {
|
||||
|
||||
@@ -2,7 +2,8 @@ import * as logs from '@pnpm/core-loggers'
|
||||
import { PackageManifest } from '@pnpm/types'
|
||||
import * as Rx from 'rxjs'
|
||||
import { filter, map, mapTo, reduce, scan, startWith, take } from 'rxjs/operators'
|
||||
import * as R from 'ramda'
|
||||
import merge from 'ramda/src/merge'
|
||||
import difference from 'ramda/src/difference'
|
||||
|
||||
export interface PackageDiff {
|
||||
added: boolean
|
||||
@@ -103,7 +104,7 @@ export default function (
|
||||
)
|
||||
.pipe(
|
||||
take(2),
|
||||
reduce(R.merge, {} as any) // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
reduce(merge, {} as any) // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
)
|
||||
|
||||
return Rx.combineLatest(
|
||||
@@ -122,7 +123,7 @@ export default function (
|
||||
const prop = propertyByDependencyType[depType]
|
||||
const initialDeps = Object.keys(initialPackageManifest[prop] || {})
|
||||
const updatedDeps = Object.keys(updatedPackageManifest[prop] || {})
|
||||
const removedDeps = R.difference(initialDeps, updatedDeps)
|
||||
const removedDeps = difference(initialDeps, updatedDeps)
|
||||
|
||||
for (const removedDep of removedDeps) {
|
||||
if (!pkgsDiff[depType][`-${removedDep}`]) {
|
||||
@@ -134,7 +135,7 @@ export default function (
|
||||
}
|
||||
}
|
||||
|
||||
const addedDeps = R.difference(updatedDeps, initialDeps)
|
||||
const addedDeps = difference(updatedDeps, initialDeps)
|
||||
|
||||
for (const addedDep of addedDeps) {
|
||||
if (!pkgsDiff[depType][`+${addedDep}`]) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { StatsLog } from '@pnpm/core-loggers'
|
||||
import * as Rx from 'rxjs'
|
||||
import { filter, take, reduce, map } from 'rxjs/operators'
|
||||
import chalk from 'chalk'
|
||||
import * as R from 'ramda'
|
||||
import repeat from 'ramda/src/repeat'
|
||||
import stringLength from 'string-length'
|
||||
import { EOL } from '../constants'
|
||||
import {
|
||||
@@ -148,7 +148,7 @@ function padStep (s: string, step: number) {
|
||||
const sLength = stringLength(s)
|
||||
const placeholderLength = Math.ceil(sLength / step) * step
|
||||
if (sLength < placeholderLength) {
|
||||
return R.repeat(' ', placeholderLength - sLength).join('') + s
|
||||
return repeat(' ', placeholderLength - sLength).join('') + s
|
||||
}
|
||||
return s
|
||||
}
|
||||
@@ -179,5 +179,5 @@ function printPlusesAndMinuses (maxWidth: number, added: number, removed: number
|
||||
addedChars = added
|
||||
removedChars = removed
|
||||
}
|
||||
return `${R.repeat(ADDED_CHAR, addedChars).join('')}${R.repeat(REMOVED_CHAR, removedChars).join('')}`
|
||||
return `${repeat(ADDED_CHAR, addedChars).join('')}${repeat(REMOVED_CHAR, removedChars).join('')}`
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import { Config } from '@pnpm/config'
|
||||
import * as Rx from 'rxjs'
|
||||
import { map, take } from 'rxjs/operators'
|
||||
import chalk from 'chalk'
|
||||
import * as R from 'ramda'
|
||||
import semver from 'semver'
|
||||
import { EOL } from '../constants'
|
||||
import getPkgsDiff, {
|
||||
@@ -46,7 +45,7 @@ export default (
|
||||
map(([pkgsDiff]) => {
|
||||
let msg = ''
|
||||
for (const depType of ['prod', 'optional', 'peer', 'dev', 'nodeModulesOnly']) {
|
||||
const diffs = R.values(pkgsDiff[depType])
|
||||
const diffs: PackageDiff[] = Object.values(pkgsDiff[depType])
|
||||
if (diffs.length > 0) {
|
||||
msg += EOL
|
||||
if (opts.pnpmConfig?.global) {
|
||||
|
||||
@@ -18,7 +18,7 @@ import logger, {
|
||||
import { map, skip, take } from 'rxjs/operators'
|
||||
import chalk from 'chalk'
|
||||
import normalizeNewline from 'normalize-newline'
|
||||
import * as R from 'ramda'
|
||||
import repeat from 'ramda/src/repeat'
|
||||
|
||||
const WARN = chalk.bgYellow.black('\u2009WARN\u2009')
|
||||
const ERROR = chalk.bgRed.black('\u2009ERROR\u2009')
|
||||
@@ -572,7 +572,7 @@ test('prints only the added stats if nothing was removed and a lot added', (done
|
||||
error: done,
|
||||
next: output => {
|
||||
expect(output).toBe(`Packages: ${chalk.green('+100')}
|
||||
${R.repeat(ADD, 20).join('')}`)
|
||||
${repeat(ADD, 20).join('')}`)
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -595,7 +595,7 @@ test('prints only the removed stats if nothing was added and a lot removed', (do
|
||||
error: done,
|
||||
next: output => {
|
||||
expect(output).toBe(`Packages: ${chalk.red('-100')}
|
||||
${R.repeat(SUB, 20).join('')}`)
|
||||
${repeat(SUB, 20).join('')}`)
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -618,7 +618,7 @@ test('prints at least one remove sign when removed !== 0', (done) => {
|
||||
error: done,
|
||||
next: output => {
|
||||
expect(output).toBe(`Packages: ${chalk.green('+100')} ${chalk.red('-1')}
|
||||
${R.repeat(ADD, 19).join('') + SUB}`
|
||||
${repeat(ADD, 19).join('') + SUB}`
|
||||
)
|
||||
},
|
||||
})
|
||||
@@ -642,7 +642,7 @@ test('prints at least one add sign when added !== 0', (done) => {
|
||||
error: done,
|
||||
next: output => {
|
||||
expect(output).toBe(`Packages: ${chalk.green('+1')} ${chalk.red('-100')}
|
||||
${ADD + R.repeat(SUB, 19).join('')}`)
|
||||
${ADD + repeat(SUB, 19).join('')}`)
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -748,7 +748,7 @@ test('recursive installation: prints only the added stats if nothing was removed
|
||||
complete: () => done(),
|
||||
error: done,
|
||||
next: output => {
|
||||
expect(output).toBe(`pkg-1 | ${chalk.green('+190')} ${R.repeat(ADD, 12).join('')}`)
|
||||
expect(output).toBe(`pkg-1 | ${chalk.green('+190')} ${repeat(ADD, 12).join('')}`)
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -772,7 +772,7 @@ test('recursive installation: prints only the removed stats if nothing was added
|
||||
complete: () => done(),
|
||||
error: done,
|
||||
next: output => {
|
||||
expect(output).toBe(`pkg-1 | ${chalk.red('-190')} ${R.repeat(SUB, 12).join('')}`)
|
||||
expect(output).toBe(`pkg-1 | ${chalk.red('-190')} ${repeat(SUB, 12).join('')}`)
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -796,7 +796,7 @@ test('recursive installation: prints at least one remove sign when removed !== 0
|
||||
complete: () => done(),
|
||||
error: done,
|
||||
next: output => {
|
||||
expect(output).toBe(`pkg-1 | ${chalk.green('+100')} ${chalk.red('-1')} ${R.repeat(ADD, 8).join('') + SUB}`)
|
||||
expect(output).toBe(`pkg-1 | ${chalk.green('+100')} ${chalk.red('-1')} ${repeat(ADD, 8).join('') + SUB}`)
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -820,7 +820,7 @@ test('recursive installation: prints at least one add sign when added !== 0', (d
|
||||
complete: () => done(),
|
||||
error: done,
|
||||
next: output => {
|
||||
expect(output).toBe(`pkg-1 | ${chalk.green('+1')} ${chalk.red('-100')} ${ADD + R.repeat(SUB, 8).join('')}`)
|
||||
expect(output).toBe(`pkg-1 | ${chalk.green('+1')} ${chalk.red('-100')} ${ADD + repeat(SUB, 8).join('')}`)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,7 +2,8 @@ import path from 'path'
|
||||
import PnpmError from '@pnpm/error'
|
||||
import { tryReadProjectManifest } from '@pnpm/read-project-manifest'
|
||||
import { Dependencies, ProjectManifest } from '@pnpm/types'
|
||||
import * as R from 'ramda'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import omit from 'ramda/src/omit'
|
||||
|
||||
// property keys that are copied from publishConfig into the manifest
|
||||
const PUBLISH_CONFIG_WHITELIST = new Set([
|
||||
@@ -33,9 +34,9 @@ const PREPUBLISH_SCRIPTS = [
|
||||
]
|
||||
|
||||
export default async function makePublishManifest (dir: string, originalManifest: ProjectManifest) {
|
||||
const publishManifest: ProjectManifest = R.omit(['pnpm', 'scripts'], originalManifest)
|
||||
const publishManifest: ProjectManifest = omit(['pnpm', 'scripts'], originalManifest)
|
||||
if (originalManifest.scripts != null) {
|
||||
publishManifest.scripts = R.omit(PREPUBLISH_SCRIPTS, originalManifest.scripts)
|
||||
publishManifest.scripts = omit(PREPUBLISH_SCRIPTS, originalManifest.scripts)
|
||||
}
|
||||
for (const depsField of ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']) {
|
||||
const deps = await makePublishDependencies(dir, originalManifest[depsField])
|
||||
@@ -58,7 +59,7 @@ export default async function makePublishManifest (dir: string, originalManifest
|
||||
|
||||
async function makePublishDependencies (dir: string, dependencies: Dependencies | undefined) {
|
||||
if (dependencies == null) return dependencies
|
||||
const publishDependencies: Dependencies = R.fromPairs(
|
||||
const publishDependencies: Dependencies = fromPairs(
|
||||
await Promise.all(
|
||||
Object.entries(dependencies)
|
||||
.map(async ([depName, depSpec]) => [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Lockfile } from '@pnpm/lockfile-types'
|
||||
import { DependenciesField } from '@pnpm/types'
|
||||
import * as R from 'ramda'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import filterImporter from './filterImporter'
|
||||
|
||||
export default function filterLockfile (
|
||||
@@ -27,6 +27,6 @@ export default function filterLockfile (
|
||||
acc[importerId] = filterImporter(lockfile.importers[importerId], opts.include)
|
||||
return acc
|
||||
}, {}),
|
||||
packages: R.fromPairs(pairs),
|
||||
packages: fromPairs(pairs),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import pnpmLogger from '@pnpm/logger'
|
||||
import packageIsInstallable from '@pnpm/package-is-installable'
|
||||
import { DependenciesField } from '@pnpm/types'
|
||||
import * as dp from 'dependency-path'
|
||||
import * as R from 'ramda'
|
||||
import unnest from 'ramda/src/unnest'
|
||||
import filterImporter from './filterImporter'
|
||||
import LockfileMissingDependencyError from './LockfileMissingDependencyError'
|
||||
|
||||
@@ -38,7 +38,7 @@ export default function filterByImportersAndEngine (
|
||||
...(opts.include.optionalDependencies ? importer.optionalDependencies : {}),
|
||||
}))
|
||||
.map(Object.entries)
|
||||
const directDepPaths = R.unnest(importerDeps)
|
||||
const directDepPaths = unnest(importerDeps)
|
||||
.map(([pkgName, ref]) => dp.refToRelative(ref, pkgName))
|
||||
.filter((nodeId) => nodeId !== null) as string[]
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ import findWorkspacePackages from '@pnpm/find-workspace-packages'
|
||||
import matcher from '@pnpm/matcher'
|
||||
import createPkgGraph, { Package, PackageNode } from 'pkgs-graph'
|
||||
import isSubdir from 'is-subdir'
|
||||
import * as R from 'ramda'
|
||||
import difference from 'ramda/src/difference'
|
||||
import partition from 'ramda/src/partition'
|
||||
import pick from 'ramda/src/pick'
|
||||
import getChangedPkgs from './getChangedPackages'
|
||||
import parsePackageSelector, { PackageSelector } from './parsePackageSelector'
|
||||
|
||||
@@ -75,7 +77,7 @@ export async function filterPkgsBySelectorObjects<T> (
|
||||
selectedProjectsGraph: PackageGraph<T>
|
||||
unmatchedFilters: string[]
|
||||
}> {
|
||||
const [prodPackageSelectors, allPackageSelectors] = R.partition(({ followProdDepsOnly }) => !!followProdDepsOnly, packageSelectors)
|
||||
const [prodPackageSelectors, allPackageSelectors] = partition(({ followProdDepsOnly }) => !!followProdDepsOnly, packageSelectors)
|
||||
|
||||
if ((allPackageSelectors.length > 0) || (prodPackageSelectors.length > 0)) {
|
||||
let filteredGraph: FilteredGraph<T> | undefined
|
||||
@@ -125,7 +127,7 @@ export default async function filterGraph<T> (
|
||||
selectedProjectsGraph: PackageGraph<T>
|
||||
unmatchedFilters: string[]
|
||||
}> {
|
||||
const [excludeSelectors, includeSelectors] = R.partition<PackageSelector>(
|
||||
const [excludeSelectors, includeSelectors] = partition<PackageSelector>(
|
||||
(selector: PackageSelector) => selector.exclude === true,
|
||||
packageSelectors
|
||||
)
|
||||
@@ -135,8 +137,8 @@ export default async function filterGraph<T> (
|
||||
: await fg(includeSelectors)
|
||||
const exclude = await fg(excludeSelectors)
|
||||
return {
|
||||
selectedProjectsGraph: R.pick(
|
||||
R.difference(include.selected, exclude.selected),
|
||||
selectedProjectsGraph: pick(
|
||||
difference(include.selected, exclude.selected),
|
||||
pkgGraph
|
||||
),
|
||||
unmatchedFilters: [...include.unmatchedFilters, ...exclude.unmatchedFilters],
|
||||
@@ -178,7 +180,7 @@ async function _filterGraph<T> (
|
||||
if (entryPackages == null) {
|
||||
entryPackages = matchPackages(pkgGraph, selector.namePattern)
|
||||
} else {
|
||||
entryPackages = matchPackages(R.pick(entryPackages, pkgGraph), selector.namePattern)
|
||||
entryPackages = matchPackages(pick(entryPackages, pkgGraph), selector.namePattern)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import execa from 'execa'
|
||||
import isCI from 'is-ci'
|
||||
import isWindows from 'is-windows'
|
||||
import path from 'path'
|
||||
import * as R from 'ramda'
|
||||
import omit from 'ramda/src/omit'
|
||||
import tempy from 'tempy'
|
||||
import touchCB from 'touch'
|
||||
|
||||
@@ -356,7 +356,7 @@ test('select all packages except one', async () => {
|
||||
], { workspaceDir: process.cwd() })
|
||||
|
||||
expect(Object.keys(selectedProjectsGraph))
|
||||
.toStrictEqual(Object.keys(R.omit(['/packages/project-1'], PKGS_GRAPH)))
|
||||
.toStrictEqual(Object.keys(omit(['/packages/project-1'], PKGS_GRAPH)))
|
||||
})
|
||||
|
||||
test('select by parentDir and exclude one package by pattern', async () => {
|
||||
|
||||
@@ -18,7 +18,8 @@ import {
|
||||
} from '@pnpm/types'
|
||||
import rimraf from '@zkochan/rimraf'
|
||||
import pathAbsolute from 'path-absolute'
|
||||
import * as R from 'ramda'
|
||||
import clone from 'ramda/src/clone'
|
||||
import equals from 'ramda/src/equals'
|
||||
import checkCompatibility from './checkCompatibility'
|
||||
import UnexpectedStoreError from './checkCompatibility/UnexpectedStoreError'
|
||||
import UnexpectedVirtualStoreDirError from './checkCompatibility/UnexpectedVirtualStoreDirError'
|
||||
@@ -131,7 +132,7 @@ export default async function getContext<T> (
|
||||
if ((opts.hooks?.readPackage) != null) {
|
||||
for (const project of importersContext.projects) {
|
||||
project.originalManifest = project.manifest
|
||||
project.manifest = opts.hooks.readPackage(R.clone(project.manifest), project.rootDir)
|
||||
project.manifest = opts.hooks.readPackage(clone(project.manifest), project.rootDir)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +210,7 @@ async function validateModules (
|
||||
if (
|
||||
opts.forcePublicHoistPattern &&
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
!R.equals(modules.publicHoistPattern, opts.publicHoistPattern || undefined)
|
||||
!equals(modules.publicHoistPattern, opts.publicHoistPattern || undefined)
|
||||
) {
|
||||
if (opts.forceNewModules && (rootProject != null)) {
|
||||
await purgeModulesDirsOfImporter(opts.virtualStoreDir, rootProject)
|
||||
@@ -225,7 +226,7 @@ async function validateModules (
|
||||
if (opts.forceHoistPattern && (rootProject != null)) {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
if (!R.equals(opts.currentHoistPattern, opts.hoistPattern || undefined)) {
|
||||
if (!equals(opts.currentHoistPattern, opts.hoistPattern || undefined)) {
|
||||
throw new PnpmError(
|
||||
'HOIST_PATTERN_DIFF',
|
||||
'This modules directory was created using a different hoist-pattern value.' +
|
||||
@@ -261,7 +262,7 @@ async function validateModules (
|
||||
purged = true
|
||||
}
|
||||
}))
|
||||
if ((modules.registries != null) && !R.equals(opts.registries, modules.registries)) {
|
||||
if ((modules.registries != null) && !equals(opts.registries, modules.registries)) {
|
||||
if (opts.forceNewModules) {
|
||||
await Promise.all(projects.map(purgeModulesDirsOfImporter.bind(null, opts.virtualStoreDir)))
|
||||
return { purged: true }
|
||||
|
||||
@@ -12,7 +12,8 @@ import {
|
||||
} from '@pnpm/lockfile-file'
|
||||
import logger from '@pnpm/logger'
|
||||
import isCI from 'is-ci'
|
||||
import * as R from 'ramda'
|
||||
import clone from 'ramda/src/clone'
|
||||
import equals from 'ramda/src/equals'
|
||||
|
||||
export interface PnpmContext {
|
||||
currentLockfile: Lockfile
|
||||
@@ -106,7 +107,7 @@ export default async function (
|
||||
}
|
||||
}
|
||||
const wantedLockfile = files[0] ??
|
||||
(currentLockfile && R.clone(currentLockfile)) ??
|
||||
(currentLockfile && clone(currentLockfile)) ??
|
||||
createLockfileObject(importerIds, sopts)
|
||||
for (const importerId of importerIds) {
|
||||
if (!wantedLockfile.importers[importerId]) {
|
||||
@@ -117,7 +118,7 @@ export default async function (
|
||||
}
|
||||
return {
|
||||
currentLockfile,
|
||||
currentLockfileIsUpToDate: R.equals(currentLockfile, wantedLockfile),
|
||||
currentLockfileIsUpToDate: equals(currentLockfile, wantedLockfile),
|
||||
existsCurrentLockfile: files[1] != null,
|
||||
existsWantedLockfile: files[0] != null,
|
||||
wantedLockfile,
|
||||
|
||||
@@ -62,7 +62,10 @@ import * as dp from 'dependency-path'
|
||||
import pLimit from 'p-limit'
|
||||
import pathAbsolute from 'path-absolute'
|
||||
import pathExists from 'path-exists'
|
||||
import * as R from 'ramda'
|
||||
import equals from 'ramda/src/equals'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import omit from 'ramda/src/omit'
|
||||
import props from 'ramda/src/props'
|
||||
import realpathMissing from 'realpath-missing'
|
||||
|
||||
const brokenModulesLogger = logger('_broken_node_modules')
|
||||
@@ -227,7 +230,7 @@ export default async (opts: HeadlessOptions) => {
|
||||
} as LockfileToDepGraphOptions
|
||||
)
|
||||
if (opts.enablePnp) {
|
||||
const importerNames = R.fromPairs(
|
||||
const importerNames = fromPairs(
|
||||
opts.projects.map(({ manifest, id }) => [id, manifest.name ?? id])
|
||||
)
|
||||
await writePnpFile(filteredLockfile, {
|
||||
@@ -237,7 +240,7 @@ export default async (opts: HeadlessOptions) => {
|
||||
registries: opts.registries,
|
||||
})
|
||||
}
|
||||
const depNodes = R.values(graph)
|
||||
const depNodes = Object.values(graph)
|
||||
|
||||
statsLogger.debug({
|
||||
added: depNodes.length,
|
||||
@@ -279,7 +282,7 @@ export default async (opts: HeadlessOptions) => {
|
||||
// But for hoisting, we need a version of the lockfile w/o the skipped packages, so we're making a copy.
|
||||
const hoistLockfile = {
|
||||
...filteredLockfile,
|
||||
packages: R.omit(Array.from(skipped), filteredLockfile.packages),
|
||||
packages: omit(Array.from(skipped), filteredLockfile.packages),
|
||||
}
|
||||
newHoistedDependencies = await hoist({
|
||||
lockfile: hoistLockfile,
|
||||
@@ -315,7 +318,7 @@ export default async (opts: HeadlessOptions) => {
|
||||
} else {
|
||||
const directNodes = new Set<string>()
|
||||
for (const id of importerIds) {
|
||||
R
|
||||
Object
|
||||
.values(directDependenciesByImporterId[id])
|
||||
.filter((loc) => graph[loc])
|
||||
.forEach((loc) => {
|
||||
@@ -366,7 +369,7 @@ export default async (opts: HeadlessOptions) => {
|
||||
|
||||
await linkAllBins(graph, { optional: opts.include.optionalDependencies, warn })
|
||||
|
||||
if ((currentLockfile != null) && !R.equals(importerIds.sort(), Object.keys(filteredLockfile.importers).sort())) {
|
||||
if ((currentLockfile != null) && !equals(importerIds.sort(), Object.keys(filteredLockfile.importers).sort())) {
|
||||
Object.assign(filteredLockfile.packages, currentLockfile.packages)
|
||||
}
|
||||
await writeCurrentLockfile(virtualStoreDir, filteredLockfile)
|
||||
@@ -585,8 +588,8 @@ async function lockfileToDepGraph (
|
||||
}
|
||||
const dir = path.join(modules, pkgName)
|
||||
if (
|
||||
currentPackages[depPath] && R.equals(currentPackages[depPath].dependencies, lockfile.packages![depPath].dependencies) &&
|
||||
R.equals(currentPackages[depPath].optionalDependencies, lockfile.packages![depPath].optionalDependencies)
|
||||
currentPackages[depPath] && equals(currentPackages[depPath].dependencies, lockfile.packages![depPath].dependencies) &&
|
||||
equals(currentPackages[depPath].optionalDependencies, lockfile.packages![depPath].optionalDependencies)
|
||||
) {
|
||||
if (await pathExists(dir)) {
|
||||
return
|
||||
@@ -644,7 +647,7 @@ async function lockfileToDepGraph (
|
||||
modules,
|
||||
name: pkgName,
|
||||
optional: !!pkgSnapshot.optional,
|
||||
optionalDependencies: new Set(R.keys(pkgSnapshot.optionalDependencies)),
|
||||
optionalDependencies: new Set(Object.keys(pkgSnapshot.optionalDependencies ?? {})),
|
||||
prepare: pkgSnapshot.prepare === true,
|
||||
requiresBuild: pkgSnapshot.requiresBuild === true,
|
||||
}
|
||||
@@ -663,7 +666,7 @@ async function lockfileToDepGraph (
|
||||
storeDir: opts.storeDir,
|
||||
virtualStoreDir: opts.virtualStoreDir,
|
||||
}
|
||||
for (const dir of R.keys(graph)) {
|
||||
for (const dir of Object.keys(graph)) {
|
||||
const pkgSnapshot = pkgSnapshotByLocation[dir]
|
||||
const allDeps = {
|
||||
...pkgSnapshot.dependencies,
|
||||
@@ -796,7 +799,7 @@ async function linkAllBins (
|
||||
}
|
||||
) {
|
||||
return Promise.all(
|
||||
R.values(depGraph)
|
||||
Object.values(depGraph)
|
||||
.map(async (depNode) => limitLinking(async () => {
|
||||
const childrenToLink = opts.optional
|
||||
? depNode.children
|
||||
@@ -809,7 +812,7 @@ async function linkAllBins (
|
||||
}, {})
|
||||
|
||||
const binPath = path.join(depNode.dir, 'node_modules/.bin')
|
||||
const pkgSnapshots = R.props<string, DependenciesGraphNode>(R.values(childrenToLink), depGraph)
|
||||
const pkgSnapshots = props<string, DependenciesGraphNode>(Object.values(childrenToLink), depGraph)
|
||||
|
||||
if (pkgSnapshots.includes(undefined as any)) { // eslint-disable-line
|
||||
await linkBins(depNode.modules, binPath, { warn: opts.warn })
|
||||
|
||||
@@ -11,7 +11,6 @@ import matcher from '@pnpm/matcher'
|
||||
import symlinkDependency from '@pnpm/symlink-dependency'
|
||||
import { HoistedDependencies } from '@pnpm/types'
|
||||
import * as dp from 'dependency-path'
|
||||
import * as R from 'ramda'
|
||||
|
||||
const hoistLogger = logger('hoist')
|
||||
|
||||
@@ -151,7 +150,7 @@ async function hoistGraph (
|
||||
getAliasHoistType: GetAliasHoistType
|
||||
}
|
||||
): Promise<HoistedDependencies> {
|
||||
const hoistedAliases = new Set(R.keys(currentSpecifiers))
|
||||
const hoistedAliases = new Set(Object.keys(currentSpecifiers))
|
||||
const hoistedDependencies: HoistedDependencies = {}
|
||||
|
||||
depNodes
|
||||
|
||||
@@ -12,7 +12,12 @@ import isSubdir from 'is-subdir'
|
||||
import isWindows from 'is-windows'
|
||||
import normalizePath from 'normalize-path'
|
||||
import pSettle from 'p-settle'
|
||||
import * as R from 'ramda'
|
||||
import { KeyValuePair } from 'ramda'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import union from 'ramda/src/union'
|
||||
import unnest from 'ramda/src/unnest'
|
||||
import partition from 'ramda/src/partition'
|
||||
|
||||
const IS_WINDOWS = isWindows()
|
||||
const EXECUTABLE_SHEBANG_SUPPORTED = !IS_WINDOWS
|
||||
@@ -37,7 +42,7 @@ export default async (
|
||||
allowExoticManifests: false,
|
||||
...opts,
|
||||
}
|
||||
const allCmds = R.unnest(
|
||||
const allCmds = unnest(
|
||||
(await Promise.all(
|
||||
allDeps
|
||||
.map((depName) => path.resolve(modulesDir, depName))
|
||||
@@ -63,7 +68,7 @@ export async function linkBinsOfPackages (
|
||||
): Promise<string[]> {
|
||||
if (pkgs.length === 0) return []
|
||||
|
||||
const allCmds = R.unnest(
|
||||
const allCmds = unnest(
|
||||
(await Promise.all(
|
||||
pkgs
|
||||
.map(async (pkg) => getPackageBinsFromManifest(pkg.manifest, pkg.location))
|
||||
@@ -91,11 +96,11 @@ async function linkBins (
|
||||
|
||||
await fs.mkdir(binsDir, { recursive: true })
|
||||
|
||||
const [cmdsWithOwnName, cmdsWithOtherNames] = R.partition(({ ownName }) => ownName, allCmds)
|
||||
const [cmdsWithOwnName, cmdsWithOtherNames] = partition(({ ownName }) => ownName, allCmds)
|
||||
|
||||
const results1 = await pSettle(cmdsWithOwnName.map(async (cmd) => linkBin(cmd, binsDir)))
|
||||
|
||||
const usedNames = R.fromPairs(cmdsWithOwnName.map((cmd) => [cmd.name, cmd.name] as R.KeyValuePair<string, string>))
|
||||
const usedNames = fromPairs(cmdsWithOwnName.map((cmd) => [cmd.name, cmd.name] as KeyValuePair<string, string>))
|
||||
const results2 = await pSettle(cmdsWithOtherNames.map(async (cmd) => {
|
||||
if (usedNames[cmd.name]) {
|
||||
opts.warn(`Cannot link binary '${cmd.name}' of '${cmd.pkgName}' to '${binsDir}': binary of '${usedNames[cmd.name]}' is already linked`, 'BINARIES_CONFLICT')
|
||||
@@ -137,7 +142,7 @@ async function getPackageBins (
|
||||
return []
|
||||
}
|
||||
|
||||
if (R.isEmpty(manifest.bin) && !await isFromModules(target)) {
|
||||
if (isEmpty(manifest.bin) && !await isFromModules(target)) {
|
||||
opts.warn(`Package in ${target} must have a non-empty bin field to get bin linked.`, 'EMPTY_BIN')
|
||||
}
|
||||
|
||||
@@ -167,7 +172,7 @@ async function linkBin (cmd: CommandInfo, binsDir: string) {
|
||||
let nodePath = await getBinNodePaths(cmd.path)
|
||||
const binsParentDir = path.dirname(binsDir)
|
||||
if (path.relative(cmd.path, binsParentDir) !== '') {
|
||||
nodePath = R.union(nodePath, await getBinNodePaths(binsParentDir))
|
||||
nodePath = union(nodePath, await getBinNodePaths(binsParentDir))
|
||||
}
|
||||
return cmdShim(cmd.path, externalBinPath, {
|
||||
createPwshFile: cmd.makePowerShellShim,
|
||||
@@ -179,7 +184,7 @@ async function getBinNodePaths (target: string): Promise<string[]> {
|
||||
const targetDir = path.dirname(target)
|
||||
const targetRealPath = await fs.realpath(targetDir)
|
||||
|
||||
return R.union(
|
||||
return union(
|
||||
Module['_nodeModulePaths'](targetRealPath),
|
||||
Module['_nodeModulePaths'](targetDir)
|
||||
)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { readProjectManifestOnly } from '@pnpm/read-project-manifest'
|
||||
import { DependenciesField, Registries } from '@pnpm/types'
|
||||
import dh from 'dependencies-hierarchy'
|
||||
import * as R from 'ramda'
|
||||
import createPackagesSearcher from './createPackagesSearcher'
|
||||
import renderJson from './renderJson'
|
||||
import renderParseable from './renderParseable'
|
||||
@@ -35,7 +34,7 @@ export async function forPackages (
|
||||
const search = createPackagesSearcher(packages)
|
||||
|
||||
const pkgs = await Promise.all(
|
||||
R.toPairs(await dh(projectPaths, {
|
||||
Object.entries(await dh(projectPaths, {
|
||||
depth: opts.depth,
|
||||
include: maybeOpts?.include,
|
||||
lockfileDir: maybeOpts?.lockfileDir,
|
||||
@@ -80,7 +79,7 @@ export default async function (
|
||||
const opts = { ...DEFAULTS, ...maybeOpts }
|
||||
|
||||
const pkgs = await Promise.all(
|
||||
R.toPairs(
|
||||
Object.entries(
|
||||
opts.depth === -1
|
||||
? projectPaths.reduce((acc, projectPath) => {
|
||||
acc[projectPath] = {}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { DEPENDENCIES_FIELDS } from '@pnpm/types'
|
||||
import { PackageNode } from 'dependencies-hierarchy'
|
||||
import * as R from 'ramda'
|
||||
import sortBy from 'ramda/src/sortBy'
|
||||
import path from 'ramda/src/path'
|
||||
import { Ord } from 'ramda'
|
||||
import getPkgInfo from './getPkgInfo'
|
||||
import { PackageDependencyHierarchy } from './types'
|
||||
|
||||
const sortPackages = R.sortBy(R.path(['pkg', 'alias']) as (pkg: object) => R.Ord)
|
||||
const sortPackages = sortBy(path(['pkg', 'alias']) as (pkg: object) => Ord)
|
||||
|
||||
export default async function (
|
||||
pkgs: PackageDependencyHierarchy[],
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { PackageNode } from 'dependencies-hierarchy'
|
||||
import * as R from 'ramda'
|
||||
import sortBy from 'ramda/src/sortBy'
|
||||
import prop from 'ramda/src/prop'
|
||||
import { PackageDependencyHierarchy } from './types'
|
||||
|
||||
const sortPackages = R.sortBy(R.prop('name'))
|
||||
const sortPackages = sortBy(prop('name'))
|
||||
|
||||
export default async function (
|
||||
pkgs: PackageDependencyHierarchy[],
|
||||
|
||||
@@ -4,11 +4,13 @@ import { DEPENDENCIES_FIELDS } from '@pnpm/types'
|
||||
import archy from 'archy'
|
||||
import chalk from 'chalk'
|
||||
import cliColumns from 'cli-columns'
|
||||
import * as R from 'ramda'
|
||||
import sortBy from 'ramda/src/sortBy'
|
||||
import rpath from 'ramda/src/path'
|
||||
import { Ord } from 'ramda'
|
||||
import getPkgInfo from './getPkgInfo'
|
||||
import { PackageDependencyHierarchy } from './types'
|
||||
|
||||
const sortPackages = R.sortBy(R.path(['name']) as (pkg: object) => R.Ord)
|
||||
const sortPackages = sortBy(rpath(['name']) as (pkg: object) => Ord)
|
||||
|
||||
const DEV_DEP_ONLY_CLR = chalk.yellow
|
||||
const PROD_DEP_CLR = (s: string) => s // just use the default color
|
||||
|
||||
@@ -5,7 +5,8 @@ import { Lockfile, ProjectSnapshot } from '@pnpm/lockfile-types'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import rimraf from '@zkochan/rimraf'
|
||||
import yaml from 'js-yaml'
|
||||
import * as R from 'ramda'
|
||||
import equals from 'ramda/src/equals'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import writeFileAtomicCB from 'write-file-atomic'
|
||||
import logger from './logger'
|
||||
import { sortLockfileKeys } from './sortLockfileKeys'
|
||||
@@ -70,37 +71,37 @@ function yamlStringify (lockfile: Lockfile, forceSharedFormat: boolean) {
|
||||
}
|
||||
|
||||
function isEmptyLockfile (lockfile: Lockfile) {
|
||||
return R.values(lockfile.importers).every((importer) => R.isEmpty(importer.specifiers ?? {}) && R.isEmpty(importer.dependencies ?? {}))
|
||||
return Object.values(lockfile.importers).every((importer) => isEmpty(importer.specifiers ?? {}) && isEmpty(importer.dependencies ?? {}))
|
||||
}
|
||||
|
||||
export type LockfileFile = Omit<Lockfile, 'importers'> & Partial<ProjectSnapshot> & Partial<Pick<Lockfile, 'importers'>>
|
||||
|
||||
export function normalizeLockfile (lockfile: Lockfile, forceSharedFormat: boolean) {
|
||||
let lockfileToSave!: LockfileFile
|
||||
if (!forceSharedFormat && R.equals(R.keys(lockfile.importers), ['.'])) {
|
||||
if (!forceSharedFormat && equals(Object.keys(lockfile.importers), ['.'])) {
|
||||
lockfileToSave = {
|
||||
...lockfile,
|
||||
...lockfile.importers['.'],
|
||||
}
|
||||
delete lockfileToSave.importers
|
||||
for (const depType of DEPENDENCIES_FIELDS) {
|
||||
if (R.isEmpty(lockfileToSave[depType])) {
|
||||
if (isEmpty(lockfileToSave[depType])) {
|
||||
delete lockfileToSave[depType]
|
||||
}
|
||||
}
|
||||
if (R.isEmpty(lockfileToSave.packages) || (lockfileToSave.packages == null)) {
|
||||
if (isEmpty(lockfileToSave.packages) || (lockfileToSave.packages == null)) {
|
||||
delete lockfileToSave.packages
|
||||
}
|
||||
} else {
|
||||
lockfileToSave = {
|
||||
...lockfile,
|
||||
importers: R.keys(lockfile.importers).reduce((acc, alias) => {
|
||||
importers: Object.keys(lockfile.importers).reduce((acc, alias) => {
|
||||
const importer = lockfile.importers[alias]
|
||||
const normalizedImporter = {
|
||||
specifiers: importer.specifiers ?? {},
|
||||
}
|
||||
for (const depType of DEPENDENCIES_FIELDS) {
|
||||
if (!R.isEmpty(importer[depType] ?? {})) {
|
||||
if (!isEmpty(importer[depType] ?? {})) {
|
||||
normalizedImporter[depType] = importer[depType]
|
||||
}
|
||||
}
|
||||
@@ -108,15 +109,15 @@ export function normalizeLockfile (lockfile: Lockfile, forceSharedFormat: boolea
|
||||
return acc
|
||||
}, {}),
|
||||
}
|
||||
if (R.isEmpty(lockfileToSave.packages) || (lockfileToSave.packages == null)) {
|
||||
if (isEmpty(lockfileToSave.packages) || (lockfileToSave.packages == null)) {
|
||||
delete lockfileToSave.packages
|
||||
}
|
||||
}
|
||||
if ((lockfileToSave.overrides != null) && R.isEmpty(lockfileToSave.overrides)) {
|
||||
if ((lockfileToSave.overrides != null) && isEmpty(lockfileToSave.overrides)) {
|
||||
delete lockfileToSave.overrides
|
||||
}
|
||||
if (lockfileToSave.neverBuiltDependencies != null) {
|
||||
if (R.isEmpty(lockfileToSave.neverBuiltDependencies)) {
|
||||
if (isEmpty(lockfileToSave.neverBuiltDependencies)) {
|
||||
delete lockfileToSave.neverBuiltDependencies
|
||||
} else {
|
||||
lockfileToSave.neverBuiltDependencies = lockfileToSave.neverBuiltDependencies.sort()
|
||||
|
||||
@@ -10,7 +10,6 @@ import { Registries } from '@pnpm/types'
|
||||
import { depPathToFilename, refToRelative } from 'dependency-path'
|
||||
import { generateInlinedScript, PackageRegistry } from '@yarnpkg/pnp'
|
||||
import normalizePath from 'normalize-path'
|
||||
import * as R from 'ramda'
|
||||
|
||||
export async function lockfileToPnp (lockfileDir: string) {
|
||||
const lockfile = await readWantedLockfile(lockfileDir, { ignoreIncompatible: true })
|
||||
@@ -103,7 +102,7 @@ export function lockfileToPackageRegistry (
|
||||
packageRegistry.set(name, packageStore)
|
||||
}
|
||||
}
|
||||
for (const [relDepPath, pkgSnapshot] of R.toPairs(lockfile.packages ?? {})) {
|
||||
for (const [relDepPath, pkgSnapshot] of Object.entries(lockfile.packages ?? {})) {
|
||||
const { name, version, peersSuffix } = nameVerFromPkgSnapshot(relDepPath, pkgSnapshot)
|
||||
const pnpVersion = toPnPVersion(version, peersSuffix)
|
||||
let packageStore = packageRegistry.get(name)
|
||||
@@ -142,7 +141,7 @@ function toPackageDependenciesMap (
|
||||
},
|
||||
importerId?: string
|
||||
): Array<[string, string | [string, string]]> {
|
||||
return R.toPairs(deps).map(([depAlias, ref]) => {
|
||||
return Object.entries(deps).map(([depAlias, ref]) => {
|
||||
if (importerId && ref.startsWith('link:')) {
|
||||
return [depAlias, path.join(importerId, ref.substr(5))]
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ import {
|
||||
DEPENDENCIES_FIELDS,
|
||||
ProjectManifest,
|
||||
} from '@pnpm/types'
|
||||
import * as R from 'ramda'
|
||||
import equals from 'ramda/src/equals'
|
||||
|
||||
export default (lockfile: Lockfile, pkg: ProjectManifest, importerId: string) => {
|
||||
const importer = lockfile.importers[importerId]
|
||||
if (!importer) return false
|
||||
if (!R.equals({ ...pkg.devDependencies, ...pkg.dependencies, ...pkg.optionalDependencies }, importer.specifiers)) {
|
||||
if (!equals({ ...pkg.devDependencies, ...pkg.dependencies, ...pkg.optionalDependencies }, importer.specifiers)) {
|
||||
return false
|
||||
}
|
||||
for (const depField of DEPENDENCIES_FIELDS) {
|
||||
@@ -46,5 +46,5 @@ export default (lockfile: Lockfile, pkg: ProjectManifest, importerId: string) =>
|
||||
}
|
||||
|
||||
function countOfNonLinkedDeps (lockfileDeps: {[depName: string]: string}): number {
|
||||
return R.values(lockfileDeps).filter((ref) => !ref.includes('link:') && !ref.includes('file:')).length
|
||||
return Object.values(lockfileDeps).filter((ref) => !ref.includes('link:') && !ref.includes('file:')).length
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Lockfile, PackageSnapshot } from '@pnpm/lockfile-types'
|
||||
import { DependenciesField } from '@pnpm/types'
|
||||
import * as dp from 'dependency-path'
|
||||
import * as R from 'ramda'
|
||||
|
||||
export interface LockedDependency {
|
||||
depPath: string
|
||||
@@ -27,7 +26,7 @@ export function lockfileWalkerGroupImporterSteps (
|
||||
|
||||
return importerIds.map((importerId) => {
|
||||
const projectSnapshot = lockfile.importers[importerId]
|
||||
const entryNodes = R.toPairs({
|
||||
const entryNodes = Object.entries({
|
||||
...(opts?.include?.devDependencies === false ? {} : projectSnapshot.devDependencies),
|
||||
...(opts?.include?.dependencies === false ? {} : projectSnapshot.dependencies),
|
||||
...(opts?.include?.optionalDependencies === false ? {} : projectSnapshot.optionalDependencies),
|
||||
@@ -59,7 +58,7 @@ export default function lockfileWalker (
|
||||
|
||||
importerIds.forEach((importerId) => {
|
||||
const projectSnapshot = lockfile.importers[importerId]
|
||||
R.toPairs({
|
||||
Object.entries({
|
||||
...(opts?.include?.devDependencies === false ? {} : projectSnapshot.devDependencies),
|
||||
...(opts?.include?.dependencies === false ? {} : projectSnapshot.dependencies),
|
||||
...(opts?.include?.optionalDependencies === false ? {} : projectSnapshot.optionalDependencies),
|
||||
@@ -116,7 +115,7 @@ function step (
|
||||
}
|
||||
|
||||
function next (opts: { includeOptionalDependencies: boolean }, nextPkg: PackageSnapshot) {
|
||||
return R.toPairs({
|
||||
return Object.entries({
|
||||
...nextPkg.dependencies,
|
||||
...(opts.includeOptionalDependencies ? nextPkg.optionalDependencies : {}),
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import { pruneSharedLockfile } from '@pnpm/prune-lockfile'
|
||||
import readProjectManifest from '@pnpm/read-project-manifest'
|
||||
import { DEPENDENCIES_FIELDS } from '@pnpm/types'
|
||||
import * as R from 'ramda'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import renameOverwrite from 'rename-overwrite'
|
||||
|
||||
export default async function (lockfileDir: string, projectDir: string) {
|
||||
@@ -75,7 +75,7 @@ function projectSnapshotWithoutLinkedDeps (projectSnapshot: ProjectSnapshot) {
|
||||
}
|
||||
for (const depField of DEPENDENCIES_FIELDS) {
|
||||
if (projectSnapshot[depField] == null) continue
|
||||
newProjectSnapshot[depField] = R.fromPairs(
|
||||
newProjectSnapshot[depField] = fromPairs(
|
||||
Object.entries(projectSnapshot[depField]!)
|
||||
.filter(([depName, depVersion]) => !depVersion.startsWith('link:'))
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Lockfile } from '@pnpm/lockfile-types'
|
||||
import comverToSemver from 'comver-to-semver'
|
||||
import * as R from 'ramda'
|
||||
import semver from 'semver'
|
||||
|
||||
export default function mergeLockfileChanges (ours: Lockfile, theirs: Lockfile) {
|
||||
@@ -65,7 +64,7 @@ function mergeDict<T> (
|
||||
valueMerger: ValueMerger<T>
|
||||
) {
|
||||
const newDict = {}
|
||||
for (const key of R.keys(ourDict).concat(R.keys(theirDict))) {
|
||||
for (const key of Object.keys(ourDict).concat(Object.keys(theirDict))) {
|
||||
const changedValue = valueMerger(
|
||||
ourDict[key],
|
||||
theirDict[key]
|
||||
|
||||
@@ -22,7 +22,11 @@ import {
|
||||
} from '@pnpm/types'
|
||||
import { depPathToFilename } from 'dependency-path'
|
||||
import rimraf from '@zkochan/rimraf'
|
||||
import * as R from 'ramda'
|
||||
import difference from 'ramda/src/difference'
|
||||
import equals from 'ramda/src/equals'
|
||||
import mergeAll from 'ramda/src/mergeAll'
|
||||
import pickAll from 'ramda/src/pickAll'
|
||||
import props from 'ramda/src/props'
|
||||
import removeDirectDependency from './removeDirectDependency'
|
||||
|
||||
export default async function prune (
|
||||
@@ -57,8 +61,8 @@ export default async function prune (
|
||||
})
|
||||
await Promise.all(importers.map(async ({ binsDir, id, modulesDir, pruneDirectDependencies, removePackages, rootDir }) => {
|
||||
const currentImporter = opts.currentLockfile.importers[id] || {} as ProjectSnapshot
|
||||
const currentPkgs = R.toPairs(mergeDependencies(currentImporter))
|
||||
const wantedPkgs = R.toPairs(mergeDependencies(wantedLockfile.importers[id]))
|
||||
const currentPkgs = Object.entries(mergeDependencies(currentImporter))
|
||||
const wantedPkgs = Object.entries(mergeDependencies(wantedLockfile.importers[id]))
|
||||
|
||||
const allCurrentPackages = new Set(
|
||||
(pruneDirectDependencies === true || removePackages?.length)
|
||||
@@ -67,7 +71,7 @@ export default async function prune (
|
||||
)
|
||||
const depsToRemove = new Set([
|
||||
...(removePackages ?? []).filter((removePackage) => allCurrentPackages.has(removePackage)),
|
||||
...R.difference(currentPkgs, wantedPkgs).map(([depName]) => depName),
|
||||
...difference(currentPkgs, wantedPkgs).map(([depName]) => depName),
|
||||
])
|
||||
if (pruneDirectDependencies) {
|
||||
if (allCurrentPackages.size > 0) {
|
||||
@@ -100,7 +104,7 @@ export default async function prune (
|
||||
// In case installation is done on a subset of importers,
|
||||
// we may only prune dependencies that are used only by that subset of importers.
|
||||
// Otherwise, we would break the node_modules.
|
||||
const currentPkgIdsByDepPaths = R.equals(selectedImporterIds, Object.keys(opts.wantedLockfile.importers))
|
||||
const currentPkgIdsByDepPaths = equals(selectedImporterIds, Object.keys(opts.wantedLockfile.importers))
|
||||
? getPkgsDepPaths(opts.registries, opts.currentLockfile.packages ?? {}, opts.skipped)
|
||||
: getPkgsDepPathsOwnedOnlyByImporters(selectedImporterIds, opts.registries, opts.currentLockfile, opts.include, opts.skipped)
|
||||
const wantedPkgIdsByDepPaths = getPkgsDepPaths(opts.registries, wantedLockfile.packages ?? {}, opts.skipped)
|
||||
@@ -108,8 +112,8 @@ export default async function prune (
|
||||
const oldDepPaths = Object.keys(currentPkgIdsByDepPaths)
|
||||
const newDepPaths = Object.keys(wantedPkgIdsByDepPaths)
|
||||
|
||||
const orphanDepPaths = R.difference(oldDepPaths, newDepPaths)
|
||||
const orphanPkgIds = new Set(R.props<string, string>(orphanDepPaths, currentPkgIdsByDepPaths))
|
||||
const orphanDepPaths = difference(oldDepPaths, newDepPaths)
|
||||
const orphanPkgIds = new Set(props<string, string>(orphanDepPaths, currentPkgIdsByDepPaths))
|
||||
|
||||
statsLogger.debug({
|
||||
prefix: opts.lockfileDir,
|
||||
@@ -198,7 +202,7 @@ async function tryRemovePkg (lockfileDir: string, virtualStoreDir: string, pkgDi
|
||||
}
|
||||
|
||||
function mergeDependencies (projectSnapshot: ProjectSnapshot): { [depName: string]: string } {
|
||||
return R.mergeAll(
|
||||
return mergeAll(
|
||||
DEPENDENCIES_FIELDS.map((depType) => projectSnapshot[depType] ?? {})
|
||||
)
|
||||
}
|
||||
@@ -231,13 +235,13 @@ function getPkgsDepPathsOwnedOnlyByImporters (
|
||||
skipped,
|
||||
})
|
||||
const other = filterLockfileByImporters(lockfile,
|
||||
R.difference(Object.keys(lockfile.importers), importerIds),
|
||||
difference(Object.keys(lockfile.importers), importerIds),
|
||||
{
|
||||
failOnMissingDependencies: false,
|
||||
include,
|
||||
skipped,
|
||||
})
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
const packagesOfSelectedOnly = R.pickAll(R.difference(Object.keys(selected.packages!), Object.keys(other.packages!)), selected.packages!) as PackageSnapshots
|
||||
const packagesOfSelectedOnly = pickAll(difference(Object.keys(selected.packages!), Object.keys(other.packages!)), selected.packages!) as PackageSnapshots
|
||||
return getPkgsDepPaths(registries, packagesOfSelectedOnly, skipped)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
IncludedDependencies,
|
||||
ProjectManifest,
|
||||
} from '@pnpm/types'
|
||||
import * as R from 'ramda'
|
||||
import unnest from 'ramda/src/unnest'
|
||||
import { createManifestGetter, ManifestGetterOptions } from './createManifestGetter'
|
||||
import outdated, { OutdatedPackage } from './outdated'
|
||||
|
||||
@@ -23,7 +23,7 @@ export default async function outdatedDepsOfProjects (
|
||||
} & Partial<Pick<ManifestGetterOptions, 'fullMetadata' | 'storeDir' | 'lockfileDir'>>
|
||||
): Promise<OutdatedPackage[][]> {
|
||||
if (!opts.lockfileDir) {
|
||||
return R.unnest(await Promise.all(
|
||||
return unnest(await Promise.all(
|
||||
pkgs.map(async (pkg) =>
|
||||
outdatedDepsOfProjects([pkg], args, { ...opts, lockfileDir: pkg.dir })
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ import loadJsonFile from 'load-json-file'
|
||||
import pDefer from 'p-defer'
|
||||
import pathTemp from 'path-temp'
|
||||
import pShare from 'promise-share'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renameOverwrite from 'rename-overwrite'
|
||||
import ssri from 'ssri'
|
||||
import safeDeferredPromise from './safeDeferredPromise'
|
||||
@@ -50,7 +50,7 @@ import safeDeferredPromise from './safeDeferredPromise'
|
||||
const TARBALL_INTEGRITY_FILENAME = 'tarball-integrity'
|
||||
const packageRequestLogger = logger('package-requester')
|
||||
|
||||
const pickBundledManifest = R.pick([
|
||||
const pickBundledManifest = pick([
|
||||
'bin',
|
||||
'bundledDependencies',
|
||||
'bundleDependencies',
|
||||
@@ -210,7 +210,7 @@ async function resolveAndFetch (
|
||||
force: forceFetch,
|
||||
lockfileDir: options.lockfileDir,
|
||||
pkg: {
|
||||
...R.pick(['name', 'version'], manifest ?? options.currentPkg ?? {}),
|
||||
...pick(['name', 'version'], manifest ?? options.currentPkg ?? {}),
|
||||
id,
|
||||
resolution,
|
||||
},
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import path from 'path'
|
||||
import resolveWorkspaceRange from '@pnpm/resolve-workspace-range'
|
||||
import npa from '@zkochan/npm-package-arg'
|
||||
import * as R from 'ramda'
|
||||
|
||||
export interface Manifest {
|
||||
name?: string
|
||||
@@ -72,7 +71,7 @@ export default function <T> (pkgs: Array<Package & T>, opts?: {
|
||||
}
|
||||
|
||||
if (spec.type === 'directory') {
|
||||
const matchedPkg = R.values(pkgMap).find(pkg => path.relative(pkg.dir, spec.fetchSpec) === '')
|
||||
const matchedPkg = Object.values(pkgMap).find(pkg => path.relative(pkg.dir, spec.fetchSpec) === '')
|
||||
if (matchedPkg == null) {
|
||||
return ''
|
||||
}
|
||||
@@ -81,7 +80,7 @@ export default function <T> (pkgs: Array<Package & T>, opts?: {
|
||||
|
||||
if (spec.type !== 'version' && spec.type !== 'range') return ''
|
||||
|
||||
const pkgs = R.values(pkgMap).filter(pkg => pkg.manifest.name === depName)
|
||||
const pkgs = Object.values(pkgMap).filter(pkg => pkg.manifest.name === depName)
|
||||
if (pkgs.length === 0) return ''
|
||||
const versions = pkgs.filter(({ manifest }) => manifest.version)
|
||||
.map(pkg => pkg.manifest.version) as string[]
|
||||
|
||||
@@ -7,7 +7,7 @@ import { readWantedLockfile } from '@pnpm/lockfile-file'
|
||||
import { Registries } from '@pnpm/types'
|
||||
import { table } from '@zkochan/table'
|
||||
import chalk from 'chalk'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
|
||||
// eslint-disable
|
||||
@@ -30,7 +30,7 @@ export const rcOptionsTypes = cliOptionsTypes
|
||||
|
||||
export function cliOptionsTypes () {
|
||||
return {
|
||||
...R.pick([
|
||||
...pick([
|
||||
'dev',
|
||||
'json',
|
||||
'only',
|
||||
|
||||
@@ -2,13 +2,13 @@ import { docsUrl } from '@pnpm/cli-utils'
|
||||
import { FILTERING, OPTIONS, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help'
|
||||
import { types as allTypes } from '@pnpm/config'
|
||||
import PnpmError from '@pnpm/error'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
import { InstallCommandOptions } from './install'
|
||||
import installDeps from './installDeps'
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'child-concurrency',
|
||||
'engine-strict',
|
||||
'fetch-retries',
|
||||
|
||||
@@ -3,13 +3,13 @@ import { UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help'
|
||||
import { Config, types as allTypes } from '@pnpm/config'
|
||||
import { createOrConnectStoreController, CreateStoreControllerOptions } from '@pnpm/store-connection-manager'
|
||||
import { InstallOptions, mutateModules } from 'supi'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
|
||||
export const rcOptionsTypes = cliOptionsTypes
|
||||
|
||||
export function cliOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'production',
|
||||
'dev',
|
||||
], allTypes)
|
||||
|
||||
@@ -4,12 +4,12 @@ import { Config, types as allTypes } from '@pnpm/config'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { CreateStoreControllerOptions } from '@pnpm/store-connection-manager'
|
||||
import isCI from 'is-ci'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
import installDeps from './installDeps'
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'child-concurrency',
|
||||
'dev',
|
||||
'engine-strict',
|
||||
@@ -66,7 +66,7 @@ export function rcOptionsTypes () {
|
||||
|
||||
export const cliOptionsTypes = () => ({
|
||||
...rcOptionsTypes(),
|
||||
...R.pick(['force'], allTypes),
|
||||
...pick(['force'], allTypes),
|
||||
recursive: Boolean,
|
||||
})
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ import {
|
||||
} from 'supi'
|
||||
import pLimit from 'p-limit'
|
||||
import pathAbsolute from 'path-absolute'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import partition from 'ramda/src/partition'
|
||||
import renderHelp from 'render-help'
|
||||
import * as installCommand from './install'
|
||||
import getSaveType from './getSaveType'
|
||||
@@ -33,7 +34,7 @@ const installLimit = pLimit(4)
|
||||
export const rcOptionsTypes = cliOptionsTypes
|
||||
|
||||
export function cliOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'global-dir',
|
||||
'global',
|
||||
'only',
|
||||
@@ -117,7 +118,7 @@ export async function handler (
|
||||
return
|
||||
}
|
||||
|
||||
const [pkgPaths, pkgNames] = R.partition((inp) => isFilespec.test(inp), params)
|
||||
const [pkgPaths, pkgNames] = partition((inp) => isFilespec.test(inp), params)
|
||||
|
||||
if (pkgNames.length > 0) {
|
||||
let globalPkgNames!: string[]
|
||||
|
||||
@@ -3,13 +3,13 @@ import { UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help'
|
||||
import { Config, types as allTypes } from '@pnpm/config'
|
||||
import { createOrConnectStoreController, CreateStoreControllerOptions } from '@pnpm/store-connection-manager'
|
||||
import { InstallOptions, mutateModules } from 'supi'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
|
||||
export const rcOptionsTypes = cliOptionsTypes
|
||||
|
||||
export function cliOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'dev',
|
||||
'optional',
|
||||
'production',
|
||||
|
||||
@@ -15,7 +15,8 @@ import { DependenciesField } from '@pnpm/types'
|
||||
import {
|
||||
mutateModules,
|
||||
} from 'supi'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import without from 'ramda/src/without'
|
||||
import renderHelp from 'render-help'
|
||||
import getSaveType from './getSaveType'
|
||||
import recursive from './recursive'
|
||||
@@ -45,7 +46,7 @@ class RemoveMissingDepsError extends PnpmError {
|
||||
}
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'global-dir',
|
||||
'global-pnpmfile',
|
||||
'global',
|
||||
@@ -68,7 +69,7 @@ export function rcOptionsTypes () {
|
||||
|
||||
export const cliOptionsTypes = () => ({
|
||||
...rcOptionsTypes(),
|
||||
...R.pick(['force'], allTypes),
|
||||
...pick(['force'], allTypes),
|
||||
recursive: Boolean,
|
||||
})
|
||||
|
||||
@@ -171,7 +172,7 @@ export async function handler (
|
||||
? getAllDependenciesFromManifest(currentManifest)
|
||||
: currentManifest[targetDependenciesField] ?? {}
|
||||
)
|
||||
const nonMatchedDependencies = R.without(availableDependencies, params)
|
||||
const nonMatchedDependencies = without(availableDependencies, params)
|
||||
if (nonMatchedDependencies.length !== 0) {
|
||||
throw new RemoveMissingDepsError({
|
||||
availableDependencies,
|
||||
|
||||
@@ -2,11 +2,12 @@ import colorizeSemverDiff from '@pnpm/colorize-semver-diff'
|
||||
import { OutdatedPackage } from '@pnpm/outdated'
|
||||
import semverDiff from '@pnpm/semver-diff'
|
||||
import { getBorderCharacters, table } from '@zkochan/table'
|
||||
import * as R from 'ramda'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import unnest from 'ramda/src/unnest'
|
||||
|
||||
export default function (outdatedPkgsOfProjects: OutdatedPackage[]) {
|
||||
const allOutdatedPkgs = mergeOutdatedPkgs(outdatedPkgsOfProjects)
|
||||
if (R.isEmpty(allOutdatedPkgs)) {
|
||||
if (isEmpty(allOutdatedPkgs)) {
|
||||
return []
|
||||
}
|
||||
const rowsGroupedByPkgs = Object.entries(allOutdatedPkgs)
|
||||
@@ -16,7 +17,7 @@ export default function (outdatedPkgsOfProjects: OutdatedPackage[]) {
|
||||
rows: outdatedPkgsRows(Object.values(outdatedPkgs)),
|
||||
}))
|
||||
const renderedTable = alignColumns(
|
||||
R.unnest(rowsGroupedByPkgs.map(({ rows }) => rows))
|
||||
unnest(rowsGroupedByPkgs.map(({ rows }) => rows))
|
||||
)
|
||||
|
||||
const choices = []
|
||||
|
||||
@@ -10,14 +10,15 @@ import matcher from '@pnpm/matcher'
|
||||
import { outdatedDepsOfProjects } from '@pnpm/outdated'
|
||||
import { prompt } from 'enquirer'
|
||||
import chalk from 'chalk'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import unnest from 'ramda/src/unnest'
|
||||
import renderHelp from 'render-help'
|
||||
import { InstallCommandOptions } from '../install'
|
||||
import installDeps from '../installDeps'
|
||||
import getUpdateChoices from './getUpdateChoices'
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'depth',
|
||||
'dev',
|
||||
'engine-strict',
|
||||
@@ -197,7 +198,7 @@ async function interactiveUpdate (
|
||||
},
|
||||
timeout: opts.fetchTimeout,
|
||||
})
|
||||
const choices = getUpdateChoices(R.unnest(outdatedPkgsOfProjects))
|
||||
const choices = getUpdateChoices(unnest(outdatedPkgsOfProjects))
|
||||
if (choices.length === 0) {
|
||||
if (opts.latest) {
|
||||
return 'All of your dependencies are already up-to-date'
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { filterDependenciesByType, getAllDependenciesFromManifest } from '@pnpm/manifest-utils'
|
||||
import { IncludedDependencies, ProjectManifest } from '@pnpm/types'
|
||||
import * as R from 'ramda'
|
||||
import getVerSelType from 'version-selector-type'
|
||||
|
||||
export default function updateToLatestSpecsFromManifest (manifest: ProjectManifest, include: IncludedDependencies) {
|
||||
const allDeps = filterDependenciesByType(manifest, include)
|
||||
const updateSpecs = []
|
||||
for (const [depName, depVersion] of R.toPairs(allDeps)) {
|
||||
for (const [depName, depVersion] of Object.entries(allDeps)) {
|
||||
if (depVersion.startsWith('npm:')) {
|
||||
updateSpecs.push(`${depName}@${removeVersionFromSpec(depVersion)}@latest`)
|
||||
} else {
|
||||
|
||||
@@ -3,12 +3,12 @@ import { FILTERING, OPTIONS, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-
|
||||
import { Config, types as allTypes } from '@pnpm/config'
|
||||
import list, { forPackages as listForPackages } from '@pnpm/list'
|
||||
import { IncludedDependencies } from '@pnpm/types'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
import listRecursive from './recursive'
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'depth',
|
||||
'dev',
|
||||
'global-dir',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as R from 'ramda'
|
||||
import omit from 'ramda/src/omit'
|
||||
import * as list from './list'
|
||||
|
||||
export const commandNames = ['ll', 'la']
|
||||
@@ -6,7 +6,7 @@ export const commandNames = ['ll', 'la']
|
||||
export const rcOptionsTypes = list.rcOptionsTypes
|
||||
|
||||
export function cliOptionsTypes () {
|
||||
return R.omit(['long'], list.cliOptionsTypes())
|
||||
return omit(['long'], list.cliOptionsTypes())
|
||||
}
|
||||
|
||||
export const help = list.help
|
||||
|
||||
@@ -2,12 +2,12 @@ import { docsUrl } from '@pnpm/cli-utils'
|
||||
import { FILTERING, OPTIONS, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help'
|
||||
import { types as allTypes } from '@pnpm/config'
|
||||
import PnpmError from '@pnpm/error'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
import { handler as list, ListCommandOptions } from './list'
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'dev',
|
||||
'global-dir',
|
||||
'global',
|
||||
|
||||
@@ -15,7 +15,8 @@ import {
|
||||
import semverDiff from '@pnpm/semver-diff'
|
||||
import { table } from '@zkochan/table'
|
||||
import chalk from 'chalk'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import sortWith from 'ramda/src/sortWith'
|
||||
import renderHelp from 'render-help'
|
||||
import stripAnsi from 'strip-ansi'
|
||||
import wrapAnsi from 'wrap-ansi'
|
||||
@@ -27,7 +28,7 @@ import outdatedRecursive from './recursive'
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return {
|
||||
...R.pick([
|
||||
...pick([
|
||||
'depth',
|
||||
'dev',
|
||||
'global-dir',
|
||||
@@ -243,7 +244,7 @@ ${renderCurrent(outdatedPkg)} ${chalk.grey('=>')} ${renderLatest(outdatedPkg)}`
|
||||
}
|
||||
|
||||
function sortOutdatedPackages (outdatedPackages: readonly OutdatedPackage[]) {
|
||||
return R.sortWith(
|
||||
return sortWith(
|
||||
DEFAULT_COMPARATORS,
|
||||
outdatedPackages.map(toOutdatedWithVersionDiff)
|
||||
)
|
||||
|
||||
@@ -10,7 +10,8 @@ import {
|
||||
} from '@pnpm/types'
|
||||
import { table } from '@zkochan/table'
|
||||
import chalk from 'chalk'
|
||||
import * as R from 'ramda'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import sortWith from 'ramda/src/sortWith'
|
||||
import {
|
||||
getCellWidth,
|
||||
OutdatedCommandOptions,
|
||||
@@ -71,7 +72,7 @@ export default async (
|
||||
})
|
||||
}
|
||||
|
||||
if (R.isEmpty(outdatedMap)) return { output: '', exitCode: 0 }
|
||||
if (isEmpty(outdatedMap)) return { output: '', exitCode: 0 }
|
||||
|
||||
if (opts.table !== false) {
|
||||
return { output: renderOutdatedTable(outdatedMap, opts), exitCode: 1 }
|
||||
@@ -158,7 +159,7 @@ function dependentPackages ({ dependentPkgs }: OutdatedInWorkspace) {
|
||||
}
|
||||
|
||||
function sortOutdatedPackages (outdatedPackages: readonly OutdatedInWorkspace[]) {
|
||||
return R.sortWith(
|
||||
return sortWith(
|
||||
COMPARATORS,
|
||||
outdatedPackages.map(toOutdatedWithVersionDiff)
|
||||
)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { types as allTypes, UniversalOptions } from '@pnpm/config'
|
||||
import runNpm from '@pnpm/run-npm'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
import { fakeRegularManifest } from './publish'
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return {
|
||||
...cliOptionsTypes(),
|
||||
...R.pick([
|
||||
...pick([
|
||||
'npm-path',
|
||||
], allTypes),
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ import { prompt } from 'enquirer'
|
||||
import rimraf from '@zkochan/rimraf'
|
||||
import cpFile from 'cp-file'
|
||||
import fg from 'fast-glob'
|
||||
import * as R from 'ramda'
|
||||
import equals from 'ramda/src/equals'
|
||||
import pick from 'ramda/src/pick'
|
||||
import realpathMissing from 'realpath-missing'
|
||||
import renderHelp from 'render-help'
|
||||
import writeJsonFile from 'write-json-file'
|
||||
@@ -19,7 +20,7 @@ import recursivePublish, { PublishRecursiveOpts } from './recursivePublish'
|
||||
import { getCurrentBranch, isGitRepo, isRemoteHistoryClean, isWorkingTreeClean } from './gitChecks'
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'access',
|
||||
'git-checks',
|
||||
'ignore-scripts',
|
||||
@@ -233,7 +234,7 @@ export async function fakeRegularManifest (
|
||||
|
||||
const { fileName, manifest, writeProjectManifest } = await readProjectManifest(opts.dir, opts)
|
||||
const publishManifest = await exportableManifest(opts.dir, manifest)
|
||||
const replaceManifest = fileName !== 'package.json' || !R.equals(manifest, publishManifest)
|
||||
const replaceManifest = fileName !== 'package.json' || !equals(manifest, publishManifest)
|
||||
if (replaceManifest) {
|
||||
await rimraf(path.join(opts.dir, fileName))
|
||||
await writeJsonFile(path.join(opts.dir, 'package.json'), publishManifest)
|
||||
|
||||
@@ -8,7 +8,7 @@ import sortPackages from '@pnpm/sort-packages'
|
||||
import storePath from '@pnpm/store-path'
|
||||
import { Registries } from '@pnpm/types'
|
||||
import pFilter from 'p-filter'
|
||||
import R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import writeJsonFile from 'write-json-file'
|
||||
import { handler as publish } from './publish'
|
||||
|
||||
@@ -117,7 +117,7 @@ export default async function (
|
||||
recursive: false,
|
||||
}, [pkg.dir])
|
||||
if (publishResult?.manifest != null) {
|
||||
publishedPackages.push(R.pick(['name', 'version'], publishResult.manifest))
|
||||
publishedPackages.push(pick(['name', 'version'], publishResult.manifest))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import runGroups from 'run-groups'
|
||||
import npa from '@zkochan/npm-package-arg'
|
||||
import graphSequencer from 'graph-sequencer'
|
||||
import pLimit from 'p-limit'
|
||||
import * as R from 'ramda'
|
||||
import semver from 'semver'
|
||||
import extendOptions, {
|
||||
RebuildOptions,
|
||||
@@ -252,7 +251,7 @@ async function _rebuild (
|
||||
|
||||
for (const depPath of nodesToBuildAndTransitiveArray) {
|
||||
const pkgSnapshot = pkgSnapshots[depPath]
|
||||
graph.set(depPath, R.toPairs({ ...pkgSnapshot.dependencies, ...pkgSnapshot.optionalDependencies })
|
||||
graph.set(depPath, Object.entries({ ...pkgSnapshot.dependencies, ...pkgSnapshot.optionalDependencies })
|
||||
.map(([pkgName, reference]) => dp.refToRelative(reference, pkgName))
|
||||
.filter((childRelDepPath) => childRelDepPath && nodesToBuildAndTransitive.has(childRelDepPath)))
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
createOrConnectStoreController,
|
||||
CreateStoreControllerOptions,
|
||||
} from '@pnpm/store-connection-manager'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
import {
|
||||
rebuild,
|
||||
@@ -16,7 +16,7 @@ import recursive from './recursive'
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return {
|
||||
...R.pick([
|
||||
...pick([
|
||||
'npm-path',
|
||||
'reporter',
|
||||
'unsafe-perm',
|
||||
|
||||
@@ -8,7 +8,7 @@ import sortPackages from '@pnpm/sort-packages'
|
||||
import execa from 'execa'
|
||||
import pLimit from 'p-limit'
|
||||
import PATH from 'path-name'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
import existsInDir from './existsInDir'
|
||||
import {
|
||||
@@ -23,7 +23,7 @@ export const shorthands = {
|
||||
export const commandNames = ['exec']
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'bail',
|
||||
'sort',
|
||||
'unsafe-perm',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { types as allTypes } from '@pnpm/config'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
import {
|
||||
handler as run,
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return {
|
||||
...R.pick([
|
||||
...pick([
|
||||
'npm-path',
|
||||
], allTypes),
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import runLifecycleHooks, {
|
||||
RunLifecycleHookOptions,
|
||||
} from '@pnpm/lifecycle'
|
||||
import { ProjectManifest } from '@pnpm/types'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import realpathMissing from 'realpath-missing'
|
||||
import renderHelp from 'render-help'
|
||||
import runRecursive, { RecursiveRunOpts } from './runRecursive'
|
||||
@@ -48,7 +48,7 @@ export const shorthands = {
|
||||
|
||||
export function rcOptionsTypes () {
|
||||
return {
|
||||
...R.pick([
|
||||
...pick([
|
||||
'npm-path',
|
||||
], allTypes),
|
||||
}
|
||||
@@ -56,7 +56,7 @@ export function rcOptionsTypes () {
|
||||
|
||||
export function cliOptionsTypes () {
|
||||
return {
|
||||
...R.pick([
|
||||
...pick([
|
||||
'bail',
|
||||
'sort',
|
||||
'unsafe-perm',
|
||||
|
||||
@@ -3,7 +3,7 @@ import { OPTIONS, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help'
|
||||
import { types as allTypes } from '@pnpm/config'
|
||||
import PnpmError from '@pnpm/error'
|
||||
import { CreateStoreControllerOptions } from '@pnpm/store-connection-manager'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
import start from './start'
|
||||
import status from './status'
|
||||
@@ -13,7 +13,7 @@ export const rcOptionsTypes = cliOptionsTypes
|
||||
|
||||
export function cliOptionsTypes () {
|
||||
return {
|
||||
...R.pick([
|
||||
...pick([
|
||||
'store',
|
||||
'store-dir',
|
||||
], allTypes),
|
||||
|
||||
@@ -4,7 +4,7 @@ import PnpmError from '@pnpm/error'
|
||||
import logger, { LogBase } from '@pnpm/logger'
|
||||
import { createOrConnectStoreController, CreateStoreControllerOptions } from '@pnpm/store-connection-manager'
|
||||
import storePath from '@pnpm/store-path'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
import storeAdd from './storeAdd'
|
||||
import storePrune from './storePrune'
|
||||
@@ -13,7 +13,7 @@ import storeStatus from './storeStatus'
|
||||
export const rcOptionsTypes = cliOptionsTypes
|
||||
|
||||
export function cliOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'registry',
|
||||
'store',
|
||||
'store-dir',
|
||||
|
||||
@@ -7,7 +7,7 @@ import prepare from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf from '@zkochan/rimraf'
|
||||
import execa from 'execa'
|
||||
import * as R from 'ramda'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import sinon from 'sinon'
|
||||
import ssri from 'ssri'
|
||||
|
||||
@@ -106,7 +106,7 @@ test('keep dependencies used by others', async () => {
|
||||
|
||||
// all dependencies are marked as dev
|
||||
const lockfile = await project.readLockfile() as Lockfile
|
||||
expect(R.isEmpty(lockfile.packages)).toBeFalsy()
|
||||
expect(isEmpty(lockfile.packages)).toBeFalsy()
|
||||
|
||||
Object.entries(lockfile.packages ?? {}).forEach(([depPath, dep]) => expect(dep.dev).toBeTruthy())
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { types as allTypes } from '@pnpm/config'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
|
||||
export const rcOptionsTypes = cliOptionsTypes
|
||||
|
||||
export function cliOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'global',
|
||||
], allTypes)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
import { server } from '@pnpm/plugin-commands-server'
|
||||
import { setup } from '@pnpm/plugin-commands-setup'
|
||||
import { store } from '@pnpm/plugin-commands-store'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import { PnpmOptions } from '../types'
|
||||
import * as bin from './bin'
|
||||
import createCompletion from './completion'
|
||||
@@ -25,7 +25,7 @@ import * as installTest from './installTest'
|
||||
import * as recursive from './recursive'
|
||||
import * as root from './root'
|
||||
|
||||
export const GLOBAL_OPTIONS = R.pick([
|
||||
export const GLOBAL_OPTIONS = pick([
|
||||
'color',
|
||||
'dir',
|
||||
'filter',
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import path from 'path'
|
||||
import { types as allTypes } from '@pnpm/config'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import renderHelp from 'render-help'
|
||||
|
||||
export const rcOptionsTypes = cliOptionsTypes
|
||||
|
||||
export function cliOptionsTypes () {
|
||||
return R.pick([
|
||||
return pick([
|
||||
'global',
|
||||
], allTypes)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import nopt from 'nopt'
|
||||
import * as R from 'ramda'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import omit from 'ramda/src/omit'
|
||||
|
||||
export interface CompletionCtx {
|
||||
last: string
|
||||
@@ -41,8 +42,8 @@ function getOptionType (
|
||||
shorthands: Record<string, string | string[]>,
|
||||
option: string
|
||||
) {
|
||||
const allBools = R.fromPairs(Object.keys(optionTypes).map((optionName) => [optionName, Boolean]))
|
||||
const result = R.omit(['argv'], nopt(allBools, shorthands, [option], 0))
|
||||
const allBools = fromPairs(Object.keys(optionTypes).map((optionName) => [optionName, Boolean]))
|
||||
const result = omit(['argv'], nopt(allBools, shorthands, [option], 0))
|
||||
return optionTypes[Object.entries(result)[0]?.[0]]
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import parseCliArgs from './parseCliArgs'
|
||||
import initReporter, { ReporterType } from './reporter'
|
||||
import isCI from 'is-ci'
|
||||
import path from 'path'
|
||||
import * as R from 'ramda'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import stripAnsi from 'strip-ansi'
|
||||
import which from 'which'
|
||||
|
||||
@@ -186,7 +186,7 @@ export default async function run (inputArgv: string[]) {
|
||||
testPattern: config.testPattern,
|
||||
})
|
||||
config.selectedProjectsGraph = filterResults.selectedProjectsGraph
|
||||
if (R.isEmpty(config.selectedProjectsGraph)) {
|
||||
if (isEmpty(config.selectedProjectsGraph)) {
|
||||
if (!config['parseable']) {
|
||||
console.log(`No projects matched the filters in "${wsDir}"`)
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import packageManager from '@pnpm/cli-meta'
|
||||
import getConfig, { types as allTypes } from '@pnpm/config'
|
||||
import runNpm from '@pnpm/run-npm'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
|
||||
export default async function run (args: string[]) {
|
||||
const { config } = await getConfig({
|
||||
cliOptions: {},
|
||||
packageManager,
|
||||
rcOptionsTypes: {
|
||||
...R.pick([
|
||||
...pick([
|
||||
'npm-path',
|
||||
], allTypes),
|
||||
},
|
||||
|
||||
@@ -7,7 +7,10 @@ import {
|
||||
} from '@pnpm/lockfile-types'
|
||||
import { PackageManifest } from '@pnpm/types'
|
||||
import { refToRelative } from 'dependency-path'
|
||||
import * as R from 'ramda'
|
||||
import difference from 'ramda/src/difference'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import omit from 'ramda/src/omit'
|
||||
import unnest from 'ramda/src/unnest'
|
||||
|
||||
export * from '@pnpm/lockfile-types'
|
||||
|
||||
@@ -20,9 +23,9 @@ export function pruneSharedLockfile (
|
||||
const copiedPackages = (lockfile.packages == null)
|
||||
? {}
|
||||
: copyPackageSnapshots(lockfile.packages, {
|
||||
devDepPaths: R.unnest(R.values(lockfile.importers).map((deps) => resolvedDepsToDepPaths(deps.devDependencies ?? {}))),
|
||||
optionalDepPaths: R.unnest(R.values(lockfile.importers).map((deps) => resolvedDepsToDepPaths(deps.optionalDependencies ?? {}))),
|
||||
prodDepPaths: R.unnest(R.values(lockfile.importers).map((deps) => resolvedDepsToDepPaths(deps.dependencies ?? {}))),
|
||||
devDepPaths: unnest(Object.values(lockfile.importers).map((deps) => resolvedDepsToDepPaths(deps.devDependencies ?? {}))),
|
||||
optionalDepPaths: unnest(Object.values(lockfile.importers).map((deps) => resolvedDepsToDepPaths(deps.optionalDependencies ?? {}))),
|
||||
prodDepPaths: unnest(Object.values(lockfile.importers).map((deps) => resolvedDepsToDepPaths(deps.dependencies ?? {}))),
|
||||
warn: opts?.warn ?? ((msg: string) => undefined),
|
||||
})
|
||||
|
||||
@@ -30,7 +33,7 @@ export function pruneSharedLockfile (
|
||||
...lockfile,
|
||||
packages: copiedPackages,
|
||||
}
|
||||
if (R.isEmpty(prunnedLockfile.packages)) {
|
||||
if (isEmpty(prunnedLockfile.packages)) {
|
||||
delete prunnedLockfile.packages
|
||||
}
|
||||
return prunnedLockfile
|
||||
@@ -47,9 +50,9 @@ export function pruneLockfile (
|
||||
const packages: PackageSnapshots = {}
|
||||
const importer = lockfile.importers[importerId]
|
||||
const lockfileSpecs: ResolvedDependencies = importer.specifiers ?? {}
|
||||
const optionalDependencies = R.keys(pkg.optionalDependencies)
|
||||
const dependencies = R.difference(R.keys(pkg.dependencies), optionalDependencies)
|
||||
const devDependencies = R.difference(R.difference(R.keys(pkg.devDependencies), optionalDependencies), dependencies)
|
||||
const optionalDependencies = Object.keys(pkg.optionalDependencies ?? {})
|
||||
const dependencies = difference(Object.keys(pkg.dependencies ?? {}), optionalDependencies)
|
||||
const devDependencies = difference(difference(Object.keys(pkg.devDependencies ?? {}), optionalDependencies), dependencies)
|
||||
const allDeps = [
|
||||
...optionalDependencies,
|
||||
...devDependencies,
|
||||
@@ -72,7 +75,7 @@ export function pruneLockfile (
|
||||
}
|
||||
})
|
||||
if (importer.dependencies != null) {
|
||||
for (const dep of R.keys(importer.dependencies)) {
|
||||
for (const dep of Object.keys(importer.dependencies)) {
|
||||
if (
|
||||
!lockfileDependencies[dep] && importer.dependencies[dep].startsWith('link:') &&
|
||||
// If the linked dependency was removed from package.json
|
||||
@@ -95,16 +98,16 @@ export function pruneLockfile (
|
||||
lockfileVersion: lockfile.lockfileVersion || LOCKFILE_VERSION,
|
||||
packages: lockfile.packages,
|
||||
}
|
||||
if (!R.isEmpty(packages)) {
|
||||
if (!isEmpty(packages)) {
|
||||
prunnedLockfile.packages = packages
|
||||
}
|
||||
if (!R.isEmpty(lockfileDependencies)) {
|
||||
if (!isEmpty(lockfileDependencies)) {
|
||||
updatedImporter.dependencies = lockfileDependencies
|
||||
}
|
||||
if (!R.isEmpty(lockfileOptionalDependencies)) {
|
||||
if (!isEmpty(lockfileOptionalDependencies)) {
|
||||
updatedImporter.optionalDependencies = lockfileOptionalDependencies
|
||||
}
|
||||
if (!R.isEmpty(lockfileDevDependencies)) {
|
||||
if (!isEmpty(lockfileDevDependencies)) {
|
||||
updatedImporter.devDependencies = lockfileDevDependencies
|
||||
}
|
||||
return pruneSharedLockfile(prunnedLockfile, opts)
|
||||
@@ -194,7 +197,7 @@ function copyDependencySubGraph (
|
||||
} else if (depLockfile.dev === undefined && !ctx.notProdOnly.has(depPath)) {
|
||||
depLockfile.dev = false
|
||||
}
|
||||
const newDependencies = resolvedDepsToDepPaths(R.omit(Object.keys(depLockfile.peerDependencies ?? {}) ?? [], depLockfile.dependencies ?? {}))
|
||||
const newDependencies = resolvedDepsToDepPaths(omit(Object.keys(depLockfile.peerDependencies ?? {}) ?? [], depLockfile.dependencies ?? {}))
|
||||
copyDependencySubGraph(ctx, newDependencies, opts)
|
||||
const newOptionalDependencies = resolvedDepsToDepPaths(depLockfile.optionalDependencies ?? {})
|
||||
copyDependencySubGraph(ctx, newOptionalDependencies, { dev: opts.dev, optional: true })
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
ProjectManifest,
|
||||
Registries,
|
||||
} from '@pnpm/types'
|
||||
import * as R from 'ramda'
|
||||
import difference from 'ramda/src/difference'
|
||||
import depPathToRef from './depPathToRef'
|
||||
import resolveDependencyTree, {
|
||||
Importer,
|
||||
@@ -118,7 +118,7 @@ export default async function (
|
||||
|
||||
const topParents = project.manifest
|
||||
? await getTopParents(
|
||||
R.difference(
|
||||
difference(
|
||||
Object.keys(getAllDependenciesFromManifest(project.manifest)),
|
||||
resolvedImporter.directDependencies
|
||||
.filter((dep, index) => project.wantedDependencies[index].isNew === true)
|
||||
@@ -153,7 +153,7 @@ export default async function (
|
||||
})
|
||||
|
||||
for (const { id } of projectsToLink) {
|
||||
for (const [alias, depPath] of R.toPairs(dependenciesByProjectId[id])) {
|
||||
for (const [alias, depPath] of Object.entries(dependenciesByProjectId[id])) {
|
||||
const depNode = dependenciesGraph[depPath]
|
||||
if (depNode.isPure) continue
|
||||
|
||||
@@ -176,7 +176,7 @@ export default async function (
|
||||
const { newLockfile, pendingRequiresBuilds } = updateLockfile(dependenciesGraph, opts.wantedLockfile, opts.virtualStoreDir, opts.registries) // eslint-disable-line:prefer-const
|
||||
|
||||
// waiting till package requests are finished
|
||||
const waitTillAllFetchingsFinish = async () => Promise.all(R.values(resolvedPackagesByDepPath).map(async ({ finishing }) => finishing()))
|
||||
const waitTillAllFetchingsFinish = async () => Promise.all(Object.values(resolvedPackagesByDepPath).map(async ({ finishing }) => finishing()))
|
||||
|
||||
return {
|
||||
dependenciesByProjectId,
|
||||
|
||||
@@ -39,7 +39,7 @@ import {
|
||||
} from '@pnpm/types'
|
||||
import * as dp from 'dependency-path'
|
||||
import exists from 'path-exists'
|
||||
import * as R from 'ramda'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import semver from 'semver'
|
||||
import encodePkgId from './encodePkgId'
|
||||
import getNonDevWantedDependencies, { WantedDependency } from './getNonDevWantedDependencies'
|
||||
@@ -742,7 +742,7 @@ async function resolveDependency (
|
||||
) {
|
||||
pkg.deprecated = currentPkg.dependencyLockfile.deprecated
|
||||
}
|
||||
hasBin = Boolean((pkg.bin && !R.isEmpty(pkg.bin)) ?? pkg.directories?.bin)
|
||||
hasBin = Boolean((pkg.bin && !isEmpty(pkg.bin)) ?? pkg.directories?.bin)
|
||||
/* eslint-enable @typescript-eslint/dot-notation */
|
||||
}
|
||||
if (options.currentDepth === 0 && pkgResponse.body.latest && pkgResponse.body.latest !== pkg.version) {
|
||||
@@ -851,9 +851,9 @@ async function resolveDependency (
|
||||
}
|
||||
|
||||
function pkgIsLeaf (pkg: PackageManifest) {
|
||||
return R.isEmpty(pkg.dependencies ?? {}) &&
|
||||
R.isEmpty(pkg.optionalDependencies ?? {}) &&
|
||||
R.isEmpty(pkg.peerDependencies ?? {})
|
||||
return isEmpty(pkg.dependencies ?? {}) &&
|
||||
isEmpty(pkg.optionalDependencies ?? {}) &&
|
||||
isEmpty(pkg.peerDependencies ?? {})
|
||||
}
|
||||
|
||||
function getResolvedPackage (
|
||||
@@ -891,7 +891,7 @@ function getResolvedPackage (
|
||||
id: options.pkgResponse.body.id,
|
||||
name: options.pkg.name,
|
||||
optional: options.wantedDependency.optional,
|
||||
optionalDependencies: new Set(R.keys(options.pkg.optionalDependencies)),
|
||||
optionalDependencies: new Set(Object.keys(options.pkg.optionalDependencies ?? {})),
|
||||
peerDependencies: peerDependencies ?? {},
|
||||
peerDependenciesMeta: options.pkg.peerDependenciesMeta,
|
||||
prepare: options.prepare,
|
||||
@@ -923,6 +923,6 @@ function peerDependenciesWithoutOwn (pkg: PackageManifest) {
|
||||
result[peerName] = '*'
|
||||
}
|
||||
}
|
||||
if (R.isEmpty(result)) return undefined
|
||||
if (isEmpty(result)) return undefined
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
ReadPackageHook,
|
||||
Registries,
|
||||
} from '@pnpm/types'
|
||||
import * as R from 'ramda'
|
||||
import partition from 'ramda/src/partition'
|
||||
import { WantedDependency } from './getNonDevWantedDependencies'
|
||||
import {
|
||||
createNodeId,
|
||||
@@ -163,7 +163,7 @@ export default async function<T> (
|
||||
|
||||
for (const { id } of importers) {
|
||||
const directDeps = directDepsByImporterId[id]
|
||||
const [linkedDependencies, directNonLinkedDeps] = R.partition((dep) => dep.isLinkedDependency === true, directDeps) as [LinkedDependency[], PkgAddress[]]
|
||||
const [linkedDependencies, directNonLinkedDeps] = partition((dep) => dep.isLinkedDependency === true, directDeps) as [LinkedDependency[], PkgAddress[]]
|
||||
|
||||
resolvedImporters[id] = {
|
||||
directDependencies: directDeps
|
||||
|
||||
@@ -5,7 +5,10 @@ import logger from '@pnpm/logger'
|
||||
import { Dependencies } from '@pnpm/types'
|
||||
import { depPathToFilename } from 'dependency-path'
|
||||
import importFrom from 'import-from'
|
||||
import * as R from 'ramda'
|
||||
import { KeyValuePair } from 'ramda'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import scan from 'ramda/src/scan'
|
||||
import semver from 'semver'
|
||||
import {
|
||||
DependenciesTree,
|
||||
@@ -66,8 +69,8 @@ export default function<T extends PartialResolvedPackage> (
|
||||
|
||||
for (const { directNodeIdsByAlias, topParents, rootDir } of opts.projects) {
|
||||
const pkgsByName = Object.assign(
|
||||
R.fromPairs(
|
||||
topParents.map(({ name, version }: {name: string, version: string}): R.KeyValuePair<string, ParentRef> => [
|
||||
fromPairs(
|
||||
topParents.map(({ name, version }: {name: string, version: string}): KeyValuePair<string, ParentRef> => [
|
||||
name,
|
||||
{
|
||||
depth: 0,
|
||||
@@ -99,8 +102,8 @@ export default function<T extends PartialResolvedPackage> (
|
||||
})
|
||||
}
|
||||
|
||||
R.values(depGraph).forEach((node) => {
|
||||
node.children = R.keys(node.children).reduce((acc, alias) => {
|
||||
Object.values(depGraph).forEach((node) => {
|
||||
node.children = Object.keys(node.children).reduce((acc, alias) => {
|
||||
acc[alias] = pathsByNodeId[node.children[alias]] ?? node.children[alias]
|
||||
return acc
|
||||
}, {})
|
||||
@@ -108,7 +111,7 @@ export default function<T extends PartialResolvedPackage> (
|
||||
|
||||
const dependenciesByProjectId: {[id: string]: {[alias: string]: string}} = {}
|
||||
for (const { directNodeIdsByAlias, id } of opts.projects) {
|
||||
dependenciesByProjectId[id] = R.keys(directNodeIdsByAlias).reduce((rootPathsByAlias, alias) => {
|
||||
dependenciesByProjectId[id] = Object.keys(directNodeIdsByAlias).reduce((rootPathsByAlias, alias) => {
|
||||
rootPathsByAlias[alias] = pathsByNodeId[directNodeIdsByAlias[alias]]
|
||||
return rootPathsByAlias
|
||||
}, {})
|
||||
@@ -153,7 +156,7 @@ function resolvePeersOfNode<T extends PartialResolvedPackage> (
|
||||
if (
|
||||
ctx.purePkgs.has(resolvedPackage.depPath) &&
|
||||
ctx.depGraph[resolvedPackage.depPath].depth <= node.depth &&
|
||||
R.isEmpty(resolvedPackage.peerDependencies)
|
||||
isEmpty(resolvedPackage.peerDependencies)
|
||||
) {
|
||||
ctx.pathsByNodeId[nodeId] = resolvedPackage.depPath
|
||||
return { resolvedPeers: {}, missingPeers: [] }
|
||||
@@ -162,7 +165,7 @@ function resolvePeersOfNode<T extends PartialResolvedPackage> (
|
||||
node.children = node.children()
|
||||
}
|
||||
const children = node.children
|
||||
const parentPkgs = R.isEmpty(children)
|
||||
const parentPkgs = isEmpty(children)
|
||||
? parentParentPkgs
|
||||
: {
|
||||
...parentParentPkgs,
|
||||
@@ -195,7 +198,7 @@ function resolvePeersOfNode<T extends PartialResolvedPackage> (
|
||||
ctx.depGraph[hit.depPath].depth = Math.min(ctx.depGraph[hit.depPath].depth, node.depth)
|
||||
return {
|
||||
missingPeers: hit.missingPeers,
|
||||
resolvedPeers: R.fromPairs(hit.resolvedPeers),
|
||||
resolvedPeers: fromPairs(hit.resolvedPeers),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +207,7 @@ function resolvePeersOfNode<T extends PartialResolvedPackage> (
|
||||
missingPeers: missingPeersOfChildren,
|
||||
} = resolvePeersOfChildren(children, parentPkgs, ctx)
|
||||
|
||||
const { resolvedPeers, missingPeers } = R.isEmpty(resolvedPackage.peerDependencies)
|
||||
const { resolvedPeers, missingPeers } = isEmpty(resolvedPackage.peerDependencies)
|
||||
? { resolvedPeers: {}, missingPeers: [] }
|
||||
: resolvePeers({
|
||||
currentDepth: node.depth,
|
||||
@@ -221,7 +224,7 @@ function resolvePeersOfNode<T extends PartialResolvedPackage> (
|
||||
const allMissingPeers = Array.from(new Set([...missingPeersOfChildren, ...missingPeers]))
|
||||
|
||||
let depPath: string
|
||||
if (R.isEmpty(allResolvedPeers)) {
|
||||
if (isEmpty(allResolvedPeers)) {
|
||||
depPath = resolvedPackage.depPath
|
||||
} else {
|
||||
const peersFolderSuffix = createPeersFolderSuffix(
|
||||
@@ -233,7 +236,7 @@ function resolvePeersOfNode<T extends PartialResolvedPackage> (
|
||||
}
|
||||
const localLocation = path.join(ctx.virtualStoreDir, depPathToFilename(depPath, ctx.lockfileDir))
|
||||
const modules = path.join(localLocation, 'node_modules')
|
||||
const isPure = R.isEmpty(allResolvedPeers) && allMissingPeers.length === 0
|
||||
const isPure = isEmpty(allResolvedPeers) && allMissingPeers.length === 0
|
||||
if (isPure) {
|
||||
ctx.purePkgs.add(resolvedPackage.depPath)
|
||||
} else {
|
||||
@@ -333,13 +336,13 @@ function resolvePeersOfChildren<T extends PartialResolvedPackage> (
|
||||
const allResolvedPeers: Record<string, string> = {}
|
||||
const allMissingPeers = new Set<string>()
|
||||
|
||||
for (const childNodeId of R.values(children)) {
|
||||
for (const childNodeId of Object.values(children)) {
|
||||
const { resolvedPeers, missingPeers } = resolvePeersOfNode(childNodeId, parentPkgs, ctx)
|
||||
Object.assign(allResolvedPeers, resolvedPeers)
|
||||
missingPeers.forEach((missingPeer) => allMissingPeers.add(missingPeer))
|
||||
}
|
||||
|
||||
const unknownResolvedPeersOfChildren = R.keys(allResolvedPeers)
|
||||
const unknownResolvedPeersOfChildren = Object.keys(allResolvedPeers)
|
||||
.filter((alias) => !children[alias])
|
||||
.reduce((acc, peer) => {
|
||||
acc[peer] = allResolvedPeers[peer]
|
||||
@@ -419,7 +422,7 @@ function packageFriendlyId (manifest: {name: string, version: string}) {
|
||||
|
||||
function nodeIdToFriendlyPath<T extends PartialResolvedPackage> (nodeId: string, dependenciesTree: DependenciesTree<T>) {
|
||||
const parts = splitNodeId(nodeId).slice(0, -1)
|
||||
const result = R.scan((prevNodeId, pkgId) => createNodeId(prevNodeId, pkgId), '>', parts)
|
||||
const result = scan((prevNodeId, pkgId) => createNodeId(prevNodeId, pkgId), '>', parts)
|
||||
.slice(2)
|
||||
.map((nid) => (dependenciesTree[nid].resolvedPackage as ResolvedPackage).name)
|
||||
.join(' > ')
|
||||
|
||||
@@ -10,7 +10,11 @@ import { Resolution } from '@pnpm/resolver-base'
|
||||
import { Registries } from '@pnpm/types'
|
||||
import * as dp from 'dependency-path'
|
||||
import getNpmTarballUrl from 'get-npm-tarball-url'
|
||||
import * as R from 'ramda'
|
||||
import { KeyValuePair } from 'ramda'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import merge from 'ramda/src/merge'
|
||||
import partition from 'ramda/src/partition'
|
||||
import depPathToRef from './depPathToRef'
|
||||
import { ResolvedPackage } from './resolveDependencies'
|
||||
import { DependenciesGraph } from '.'
|
||||
@@ -28,7 +32,7 @@ export default function (
|
||||
const pendingRequiresBuilds = [] as string[]
|
||||
for (const depPath of Object.keys(depGraph)) {
|
||||
const depNode = depGraph[depPath]
|
||||
const [updatedOptionalDeps, updatedDeps] = R.partition(
|
||||
const [updatedOptionalDeps, updatedDeps] = partition(
|
||||
(child) => depNode.optionalDependencies.has(child.alias),
|
||||
Object.keys(depNode.children).map((alias) => ({ alias, depPath: depNode.children[alias] }))
|
||||
)
|
||||
@@ -93,10 +97,10 @@ function toLockfileDependency (
|
||||
result['version'] = pkg.version
|
||||
}
|
||||
}
|
||||
if (!R.isEmpty(newResolvedDeps)) {
|
||||
if (!isEmpty(newResolvedDeps)) {
|
||||
result['dependencies'] = newResolvedDeps
|
||||
}
|
||||
if (!R.isEmpty(newResolvedOptionalDeps)) {
|
||||
if (!isEmpty(newResolvedOptionalDeps)) {
|
||||
result['optionalDependencies'] = newResolvedOptionalDeps
|
||||
}
|
||||
if (pkg.dev && !pkg.prod) {
|
||||
@@ -110,7 +114,7 @@ function toLockfileDependency (
|
||||
if (opts.depPath[0] !== '/' && !pkg.id.endsWith(opts.depPath)) {
|
||||
result['id'] = pkg.id
|
||||
}
|
||||
if (!R.isEmpty(pkg.peerDependencies ?? {})) {
|
||||
if (!isEmpty(pkg.peerDependencies ?? {})) {
|
||||
result['peerDependencies'] = pkg.peerDependencies
|
||||
}
|
||||
if (pkg.transitivePeerDependencies.size) {
|
||||
@@ -128,7 +132,7 @@ function toLockfileDependency (
|
||||
}
|
||||
}
|
||||
if (pkg.additionalInfo.engines != null) {
|
||||
for (const engine of R.keys(pkg.additionalInfo.engines)) {
|
||||
for (const engine of Object.keys(pkg.additionalInfo.engines)) {
|
||||
if (pkg.additionalInfo.engines[engine] === '*') continue
|
||||
result['engines'] = result['engines'] || {}
|
||||
result['engines'][engine] = pkg.additionalInfo.engines[engine]
|
||||
@@ -180,9 +184,9 @@ function updateResolvedDeps (
|
||||
registries: Registries,
|
||||
depGraph: DependenciesGraph
|
||||
) {
|
||||
const newResolvedDeps = R.fromPairs<string>(
|
||||
const newResolvedDeps = fromPairs<string>(
|
||||
updatedDeps
|
||||
.map(({ alias, depPath }): R.KeyValuePair<string, string> => {
|
||||
.map(({ alias, depPath }): KeyValuePair<string, string> => {
|
||||
if (depPath.startsWith('link:')) {
|
||||
return [alias, depPath]
|
||||
}
|
||||
@@ -198,7 +202,7 @@ function updateResolvedDeps (
|
||||
]
|
||||
})
|
||||
)
|
||||
return R.merge(
|
||||
return merge(
|
||||
prevResolvedDeps,
|
||||
newResolvedDeps
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
ProjectManifest,
|
||||
} from '@pnpm/types'
|
||||
import pEvery from 'p-every'
|
||||
import * as R from 'ramda'
|
||||
import any from 'ramda/src/any'
|
||||
import semver from 'semver'
|
||||
|
||||
export default async function allProjectsAreUpToDate (
|
||||
@@ -121,9 +121,9 @@ function getVersionRange (spec: string) {
|
||||
}
|
||||
|
||||
function hasLocalTarballDepsInRoot (importer: ProjectSnapshot) {
|
||||
return R.any(refIsLocalTarball, Object.values(importer.dependencies ?? {})) ||
|
||||
R.any(refIsLocalTarball, Object.values(importer.devDependencies ?? {})) ||
|
||||
R.any(refIsLocalTarball, Object.values(importer.optionalDependencies ?? {}))
|
||||
return any(refIsLocalTarball, Object.values(importer.dependencies ?? {})) ||
|
||||
any(refIsLocalTarball, Object.values(importer.devDependencies ?? {})) ||
|
||||
any(refIsLocalTarball, Object.values(importer.optionalDependencies ?? {}))
|
||||
}
|
||||
|
||||
function refIsLocalTarball (ref: string) {
|
||||
|
||||
@@ -49,7 +49,11 @@ import rimraf from '@zkochan/rimraf'
|
||||
import isInnerLink from 'is-inner-link'
|
||||
import pFilter from 'p-filter'
|
||||
import pLimit from 'p-limit'
|
||||
import * as R from 'ramda'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import equals from 'ramda/src/equals'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import props from 'ramda/src/props'
|
||||
import unnest from 'ramda/src/unnest'
|
||||
import parseWantedDependencies from '../parseWantedDependencies'
|
||||
import safeIsInnerLink from '../safeIsInnerLink'
|
||||
import removeDeps from '../uninstall/removeDeps'
|
||||
@@ -152,7 +156,7 @@ export async function mutateModules (
|
||||
? rootProjectManifest.pnpm?.overrides ?? rootProjectManifest.resolutions
|
||||
: undefined
|
||||
const neverBuiltDependencies = rootProjectManifest?.pnpm?.neverBuiltDependencies ?? []
|
||||
if (!R.isEmpty(overrides ?? {})) {
|
||||
if (!isEmpty(overrides ?? {})) {
|
||||
const versionsOverrider = createVersionsOverrider(overrides!, opts.lockfileDir)
|
||||
if (opts.hooks.readPackage != null) {
|
||||
const readPackage = opts.hooks.readPackage
|
||||
@@ -183,8 +187,8 @@ export async function mutateModules (
|
||||
return result
|
||||
|
||||
async function _install (): Promise<Array<{ rootDir: string, manifest: ProjectManifest }>> {
|
||||
let needsFullResolution = !R.equals(ctx.wantedLockfile.overrides ?? {}, overrides ?? {}) ||
|
||||
!R.equals((ctx.wantedLockfile.neverBuiltDependencies ?? []).sort(), (neverBuiltDependencies ?? []).sort())
|
||||
let needsFullResolution = !equals(ctx.wantedLockfile.overrides ?? {}, overrides ?? {}) ||
|
||||
!equals((ctx.wantedLockfile.neverBuiltDependencies ?? []).sort(), (neverBuiltDependencies ?? []).sort())
|
||||
ctx.wantedLockfile.overrides = overrides
|
||||
ctx.wantedLockfile.neverBuiltDependencies = neverBuiltDependencies
|
||||
const frozenLockfile = opts.frozenLockfile ||
|
||||
@@ -481,9 +485,9 @@ async function isExternalLink (storeDir: string, modules: string, pkgName: strin
|
||||
|
||||
function pkgHasDependencies (manifest: ProjectManifest) {
|
||||
return Boolean(
|
||||
(R.keys(manifest.dependencies).length > 0) ||
|
||||
R.keys(manifest.devDependencies).length ||
|
||||
R.keys(manifest.optionalDependencies).length
|
||||
(Object.keys(manifest.dependencies ?? {}).length > 0) ||
|
||||
Object.keys(manifest.devDependencies ?? {}).length ||
|
||||
Object.keys(manifest.optionalDependencies ?? {}).length
|
||||
)
|
||||
}
|
||||
|
||||
@@ -652,7 +656,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
|
||||
(
|
||||
!opts.update &&
|
||||
(ctx.wantedLockfile.packages != null) &&
|
||||
!R.isEmpty(ctx.wantedLockfile.packages)
|
||||
!isEmpty(ctx.wantedLockfile.packages)
|
||||
)
|
||||
? getPreferredVersionsFromLockfile(ctx.wantedLockfile.packages)
|
||||
: undefined
|
||||
@@ -756,7 +760,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
|
||||
)
|
||||
await finishLockfileUpdates()
|
||||
if (opts.enablePnp) {
|
||||
const importerNames = R.fromPairs(
|
||||
const importerNames = fromPairs(
|
||||
projects.map(({ manifest, id }) => [id, manifest.name ?? id])
|
||||
)
|
||||
await writePnpFile(result.currentLockfile, {
|
||||
@@ -806,7 +810,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
|
||||
|
||||
const binWarn = (prefix: string, message: string) => logger.info({ message, prefix })
|
||||
if (result.newDepPaths?.length) {
|
||||
const newPkgs = R.props<string, DependenciesGraphNode>(result.newDepPaths, dependenciesGraph)
|
||||
const newPkgs = props<string, DependenciesGraphNode>(result.newDepPaths, dependenciesGraph)
|
||||
await linkAllBins(newPkgs, dependenciesGraph, {
|
||||
optional: opts.include.optionalDependencies,
|
||||
warn: binWarn.bind(null, opts.lockfileDir),
|
||||
@@ -822,7 +826,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
|
||||
})
|
||||
} else {
|
||||
const directPkgs = [
|
||||
...R.props<string, DependenciesGraphNode>(
|
||||
...props<string, DependenciesGraphNode>(
|
||||
Object.values(dependenciesByProjectId[project.id]).filter((depPath) => !ctx.skipped.has(depPath)),
|
||||
dependenciesGraph
|
||||
),
|
||||
@@ -998,7 +1002,7 @@ async function linkAllBins (
|
||||
warn: (message: string) => void
|
||||
}
|
||||
) {
|
||||
return R.unnest(await Promise.all(
|
||||
return unnest(await Promise.all(
|
||||
depNodes.map(async depNode => limitLinking(async () => linkBinsOfDependencies(depNode, depGraph, opts)))
|
||||
))
|
||||
}
|
||||
|
||||
@@ -29,7 +29,11 @@ import {
|
||||
} from '@pnpm/types'
|
||||
import pLimit from 'p-limit'
|
||||
import pathExists from 'path-exists'
|
||||
import * as R from 'ramda'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import equals from 'ramda/src/equals'
|
||||
import difference from 'ramda/src/difference'
|
||||
import omit from 'ramda/src/omit'
|
||||
import props from 'ramda/src/props'
|
||||
|
||||
const brokenModulesLogger = logger('_broken_node_modules')
|
||||
|
||||
@@ -70,7 +74,7 @@ export default async function linkPackages (
|
||||
newHoistedDependencies: HoistedDependencies
|
||||
removedDepPaths: Set<string>
|
||||
}> {
|
||||
let depNodes = R.values(depGraph).filter(({ depPath, id }) => {
|
||||
let depNodes = Object.values(depGraph).filter(({ depPath, id }) => {
|
||||
if (((opts.wantedLockfile.packages?.[depPath]) != null) && !opts.wantedLockfile.packages[depPath].optional) {
|
||||
opts.skipped.delete(depPath)
|
||||
return true
|
||||
@@ -91,7 +95,7 @@ export default async function linkPackages (
|
||||
if (!opts.include.optionalDependencies) {
|
||||
depNodes = depNodes.filter(({ optional }) => !optional)
|
||||
}
|
||||
depGraph = R.fromPairs(depNodes.map((depNode) => [depNode.depPath, depNode]))
|
||||
depGraph = fromPairs(depNodes.map((depNode) => [depNode.depPath, depNode]))
|
||||
const removedDepPaths = await prune(projects, {
|
||||
currentLockfile: opts.currentLockfile,
|
||||
hoistedDependencies: opts.hoistedDependencies,
|
||||
@@ -192,7 +196,7 @@ export default async function linkPackages (
|
||||
}
|
||||
|
||||
let currentLockfile: Lockfile
|
||||
const allImportersIncluded = R.equals(projectIds.sort(), Object.keys(opts.wantedLockfile.importers).sort())
|
||||
const allImportersIncluded = equals(projectIds.sort(), Object.keys(opts.wantedLockfile.importers).sort())
|
||||
if (
|
||||
opts.makePartialCurrentLockfile ||
|
||||
!allImportersIncluded
|
||||
@@ -239,7 +243,7 @@ export default async function linkPackages (
|
||||
// But for hoisting, we need a version of the lockfile w/o the skipped packages, so we're making a copy.
|
||||
const hoistLockfile = {
|
||||
...currentLockfile,
|
||||
packages: R.omit(Array.from(opts.skipped), currentLockfile.packages),
|
||||
packages: omit(Array.from(opts.skipped), currentLockfile.packages),
|
||||
}
|
||||
newHoistedDependencies = await hoist({
|
||||
lockfile: hoistLockfile,
|
||||
@@ -285,7 +289,7 @@ async function linkNewPackages (
|
||||
virtualStoreDir: string
|
||||
}
|
||||
): Promise<string[]> {
|
||||
const wantedRelDepPaths = R.difference(R.keys(wantedLockfile.packages), Array.from(opts.skipped))
|
||||
const wantedRelDepPaths = difference(Object.keys(wantedLockfile.packages ?? {}), Array.from(opts.skipped))
|
||||
|
||||
let newDepPathsSet: Set<string>
|
||||
if (opts.force) {
|
||||
@@ -310,8 +314,8 @@ async function linkNewPackages (
|
||||
// TODO: no need to relink everything. Can be relinked only what was changed
|
||||
for (const depPath of wantedRelDepPaths) {
|
||||
if (currentLockfile.packages[depPath] &&
|
||||
(!R.equals(currentLockfile.packages[depPath].dependencies, wantedLockfile.packages[depPath].dependencies) ||
|
||||
!R.equals(currentLockfile.packages[depPath].optionalDependencies, wantedLockfile.packages[depPath].optionalDependencies))) {
|
||||
(!equals(currentLockfile.packages[depPath].dependencies, wantedLockfile.packages[depPath].dependencies) ||
|
||||
!equals(currentLockfile.packages[depPath].optionalDependencies, wantedLockfile.packages[depPath].optionalDependencies))) {
|
||||
// TODO: come up with a test that triggers the usecase of depGraph[depPath] undefined
|
||||
// see related issue: https://github.com/pnpm/pnpm/issues/870
|
||||
if (depGraph[depPath] && !newDepPathsSet.has(depPath)) {
|
||||
@@ -325,7 +329,7 @@ async function linkNewPackages (
|
||||
|
||||
const newDepPaths = Array.from(newDepPathsSet)
|
||||
|
||||
const newPkgs = R.props<string, DependenciesGraphNode>(newDepPaths, depGraph)
|
||||
const newPkgs = props<string, DependenciesGraphNode>(newDepPaths, depGraph)
|
||||
|
||||
await Promise.all(newPkgs.map(async (depNode) => fs.mkdir(depNode.modules, { recursive: true })))
|
||||
await Promise.all([
|
||||
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
} from '@pnpm/types'
|
||||
import normalize from 'normalize-path'
|
||||
import pathAbsolute from 'path-absolute'
|
||||
import * as R from 'ramda'
|
||||
import clone from 'ramda/src/clone'
|
||||
import {
|
||||
extendOptions,
|
||||
LinkOptions,
|
||||
@@ -56,7 +56,7 @@ export default async function link (
|
||||
})
|
||||
|
||||
const importerId = getLockfileImporterId(ctx.lockfileDir, opts.dir)
|
||||
const currentLockfile = R.clone(ctx.currentLockfile)
|
||||
const currentLockfile = clone(ctx.currentLockfile)
|
||||
const linkedPkgs: Array<{path: string, manifest: DependencyManifest, alias: string}> = []
|
||||
const specsToUpsert = [] as PackageSpecObject[]
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import rimraf from '@zkochan/rimraf'
|
||||
import R from 'ramda'
|
||||
import clone from 'ramda/src/clone'
|
||||
import {
|
||||
addDependenciesToPackage,
|
||||
mutateModules,
|
||||
@@ -24,7 +24,7 @@ test('installation breaks if the lockfile contains the wrong checksum', async ()
|
||||
)
|
||||
|
||||
const corruptedLockfile = await project.readLockfile()
|
||||
const correctLockfile = R.clone(corruptedLockfile)
|
||||
const correctLockfile = clone(corruptedLockfile)
|
||||
// breaking the lockfile
|
||||
corruptedLockfile.packages['/pkg-with-1-dep/100.0.0'].resolution['integrity'] = corruptedLockfile.packages['/dep-of-pkg-with-1-dep/100.0.0'].resolution['integrity']
|
||||
await writeYamlFile(WANTED_LOCKFILE, corruptedLockfile, { lineWidth: 1000 })
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from 'supi'
|
||||
import rimraf from '@zkochan/rimraf'
|
||||
import exists from 'path-exists'
|
||||
import * as R from 'ramda'
|
||||
import pick from 'ramda/src/pick'
|
||||
import sinon from 'sinon'
|
||||
import writeYamlFile from 'write-yaml-file'
|
||||
import { addDistTag, testDefaults } from '../utils'
|
||||
@@ -198,7 +198,7 @@ test('some projects were removed from the workspace and the ones that are left d
|
||||
await expect(
|
||||
mutateModules([importers[0]], await testDefaults({
|
||||
pruneLockfileImporters: true,
|
||||
workspacePackages: R.pick(['project-1'], workspacePackages),
|
||||
workspacePackages: pick(['project-1'], workspacePackages),
|
||||
} as any)) // eslint-disable-line
|
||||
).rejects.toThrow(/No matching version found for/)
|
||||
})
|
||||
|
||||
@@ -18,7 +18,6 @@ import rimraf from '@zkochan/rimraf'
|
||||
import loadJsonFile from 'load-json-file'
|
||||
import nock from 'nock'
|
||||
import exists from 'path-exists'
|
||||
import * as R from 'ramda'
|
||||
import sinon from 'sinon'
|
||||
import writeYamlFile from 'write-yaml-file'
|
||||
import {
|
||||
@@ -608,7 +607,7 @@ test('dev properties are correctly updated on named install', async () => {
|
||||
|
||||
const lockfile = await project.readLockfile()
|
||||
expect(
|
||||
R.values(lockfile.packages).filter((dep) => typeof dep.dev !== 'undefined')
|
||||
Object.values(lockfile.packages).filter((dep) => typeof dep.dev !== 'undefined')
|
||||
).toStrictEqual([])
|
||||
})
|
||||
|
||||
@@ -619,7 +618,7 @@ test('optional properties are correctly updated on named install', async () => {
|
||||
await addDependenciesToPackage(manifest, ['foo@npm:inflight@1.0.6'], await testDefaults({}))
|
||||
|
||||
const lockfile = await project.readLockfile()
|
||||
expect(R.values(lockfile.packages).filter((dep) => typeof dep.optional !== 'undefined')).toStrictEqual([])
|
||||
expect(Object.values(lockfile.packages).filter((dep) => typeof dep.optional !== 'undefined')).toStrictEqual([])
|
||||
})
|
||||
|
||||
test('dev property is correctly set for package that is duplicated to both the dependencies and devDependencies group', async () => {
|
||||
@@ -937,7 +936,7 @@ test(`doing named installation when shared ${WANTED_LOCKFILE} exists already`, a
|
||||
|
||||
const currentLockfile = await readYamlFile<Lockfile>(path.resolve('node_modules/.pnpm/lock.yaml'))
|
||||
|
||||
expect(R.keys(currentLockfile['importers'])).toStrictEqual(['pkg2'])
|
||||
expect(Object.keys(currentLockfile['importers'])).toStrictEqual(['pkg2'])
|
||||
|
||||
await mutateModules(
|
||||
[
|
||||
|
||||
@@ -12,7 +12,8 @@ import {
|
||||
import { FetchFromRegistry } from '@pnpm/fetching-types'
|
||||
import preparePackage from '@pnpm/prepare-package'
|
||||
import * as retry from '@zkochan/retry'
|
||||
import R from 'ramda'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import omit from 'ramda/src/omit'
|
||||
import ssri from 'ssri'
|
||||
import { BadTarballError } from './errorTypes'
|
||||
|
||||
@@ -212,14 +213,14 @@ function isGitHostedPkgUrl (url: string) {
|
||||
}
|
||||
|
||||
export async function waitForFilesIndex (filesIndex: FilesIndex): Promise<Record<string, PackageFileInfo>> {
|
||||
return R.fromPairs(
|
||||
return fromPairs(
|
||||
await Promise.all(
|
||||
Object.entries(filesIndex).map(async ([fileName, fileInfo]): Promise<[string, PackageFileInfo]> => {
|
||||
const { integrity, checkedAt } = await fileInfo.writeResult
|
||||
return [
|
||||
fileName,
|
||||
{
|
||||
...R.omit(['writeResult'], fileInfo),
|
||||
...omit(['writeResult'], fileInfo),
|
||||
checkedAt,
|
||||
integrity: integrity.toString(),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user