mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-24 18:11:39 -04:00
committed by
Zoltan Kochan
parent
22d4dfa97b
commit
de79f13136
@@ -261,10 +261,16 @@ function getHelpText (command: string) {
|
||||
|
||||
* * *
|
||||
|
||||
pnpm recursive list
|
||||
pnpm recursive list [[<@scope>/]<pkg> ...]
|
||||
|
||||
List packages in each project of the multi-package repo.
|
||||
Accepts the same arguments and flags as the regular \`pnpm list\` command.
|
||||
|
||||
* * *
|
||||
|
||||
pnpm recursive outdated [[<@scope>/]<pkg> ...]
|
||||
|
||||
Check for outdated packages in every project of the multi-package repo.
|
||||
`
|
||||
|
||||
default:
|
||||
@@ -291,6 +297,7 @@ function getHelpText (command: string) {
|
||||
- recursive install
|
||||
- recursive update
|
||||
- recursive list
|
||||
- recursive outdated
|
||||
|
||||
Experimental commands:
|
||||
- server start
|
||||
|
||||
@@ -20,6 +20,7 @@ import getCommandFullName from '../../getCommandFullName'
|
||||
import requireHooks from '../../requireHooks'
|
||||
import {PnpmOptions} from '../../types'
|
||||
import list from './list'
|
||||
import outdated from './outdated'
|
||||
|
||||
const supportedRecursiveCommands = new Set([
|
||||
'install',
|
||||
@@ -27,6 +28,7 @@ const supportedRecursiveCommands = new Set([
|
||||
'link',
|
||||
'unlink',
|
||||
'list',
|
||||
'outdated',
|
||||
])
|
||||
|
||||
export default async (
|
||||
@@ -61,13 +63,19 @@ export default async (
|
||||
],
|
||||
patterns: packagesManifest && packagesManifest.packages || undefined,
|
||||
})
|
||||
if (cmdFullName === 'list') {
|
||||
await list(pkgs, input, cmd, opts as any) // tslint:disable-line:no-any
|
||||
return
|
||||
}
|
||||
if (cmdFullName === 'update') {
|
||||
opts = {...opts, update: true}
|
||||
|
||||
switch (cmdFullName) {
|
||||
case 'list':
|
||||
await list(pkgs, input, cmd, opts as any) // tslint:disable-line:no-any
|
||||
return
|
||||
case 'outdated':
|
||||
await outdated(pkgs, input, cmd, opts as any) // tslint:disable-line:no-any
|
||||
return
|
||||
case 'update':
|
||||
opts = {...opts, update: true}
|
||||
break
|
||||
}
|
||||
|
||||
const pkgGraphResult = createPkgGraph(pkgs)
|
||||
const store = await createStoreController(opts)
|
||||
|
||||
|
||||
66
packages/pnpm/src/cmd/recursive/outdated.ts
Normal file
66
packages/pnpm/src/cmd/recursive/outdated.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import outdated, {
|
||||
forPackages as outdatedForPackages,
|
||||
} from '@pnpm/outdated'
|
||||
import {PackageJson} from '@pnpm/types'
|
||||
import chalk from 'chalk'
|
||||
import path = require('path')
|
||||
import stripColor = require('strip-color')
|
||||
import table = require('text-table')
|
||||
|
||||
export default async (
|
||||
pkgs: Array<{path: string, manifest: PackageJson}>,
|
||||
args: string[],
|
||||
cmd: string,
|
||||
opts: {
|
||||
prefix: string,
|
||||
global: boolean,
|
||||
independentLeaves: boolean,
|
||||
offline: boolean,
|
||||
store: string,
|
||||
proxy?: string,
|
||||
httpsProxy?: string,
|
||||
localAddress?: string,
|
||||
cert?: string,
|
||||
key?: string,
|
||||
ca?: string,
|
||||
strictSsl: boolean,
|
||||
fetchRetries: number,
|
||||
fetchRetryFactor: number,
|
||||
fetchRetryMintimeout: number,
|
||||
fetchRetryMaxtimeout: number,
|
||||
userAgent: string,
|
||||
tag: string,
|
||||
networkConcurrency: number,
|
||||
rawNpmConfig: object,
|
||||
alwaysAuth: boolean,
|
||||
},
|
||||
) => {
|
||||
const outdatedPkgs = [] as Array<{
|
||||
packageName: string,
|
||||
current?: string,
|
||||
wanted: string,
|
||||
latest?: string,
|
||||
prefix: string,
|
||||
}>
|
||||
const getOutdated = args.length ? outdatedForPackages.bind(null, args) : outdated
|
||||
for (const pkg of pkgs) {
|
||||
const op = await getOutdated(pkg.path, opts)
|
||||
const prefix = path.relative(opts.prefix, pkg.path)
|
||||
op.forEach((outdatedPkg: any) => outdatedPkgs.push({...outdatedPkg, prefix})) // tslint:disable-line:no-any
|
||||
}
|
||||
|
||||
const columnNames = ['', 'Package', 'Current', 'Wanted', 'Latest'].map((txt) => chalk.underline(txt))
|
||||
console.log(
|
||||
table([columnNames].concat(
|
||||
outdatedPkgs.map((outdatedPkg) => [
|
||||
outdatedPkg.prefix,
|
||||
chalk.yellow(outdatedPkg.packageName),
|
||||
outdatedPkg.current || 'missing',
|
||||
chalk.green(outdatedPkg.wanted),
|
||||
chalk.magenta(outdatedPkg.latest || ''),
|
||||
]),
|
||||
), {
|
||||
stringLength: (s: string) => stripColor(s).length,
|
||||
}),
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import {stripIndent} from 'common-tags'
|
||||
import {stripIndent, stripIndents} from 'common-tags'
|
||||
import delay = require('delay')
|
||||
import fs = require('mz/fs')
|
||||
import isCI = require('is-ci')
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
spawn,
|
||||
} from './utils'
|
||||
import mkdirp = require('mkdirp-promise')
|
||||
import normalizeNewline = require('normalize-newline')
|
||||
import loadYamlFile = require('load-yaml-file')
|
||||
|
||||
const test = promisifyTape(tape)
|
||||
@@ -407,3 +408,47 @@ test('recursive list', async (t: tape.Test) => {
|
||||
└── is-negative@1.0.0
|
||||
` + '\n\n')
|
||||
})
|
||||
|
||||
test('pnpm recursive outdated', async (t: tape.Test) => {
|
||||
const projects = prepare(t, [
|
||||
{
|
||||
name: 'project-1',
|
||||
version: '1.0.0',
|
||||
dependencies: {
|
||||
'is-positive': '1.0.0',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'project-2',
|
||||
version: '1.0.0',
|
||||
dependencies: {
|
||||
'is-negative': '1.0.0',
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
await execPnpm('recursive', 'install')
|
||||
|
||||
{
|
||||
const result = execPnpmSync('recursive', 'outdated')
|
||||
|
||||
t.equal(result.status, 0)
|
||||
|
||||
t.equal(normalizeNewline(result.stdout.toString()), ' ' + stripIndents`
|
||||
Package Current Wanted Latest
|
||||
project-1 is-positive 1.0.0 1.0.0 3.1.0
|
||||
project-2 is-negative 1.0.0 1.0.0 2.1.0
|
||||
` + '\n')
|
||||
}
|
||||
|
||||
{
|
||||
const result = execPnpmSync('recursive', 'outdated', 'is-positive')
|
||||
|
||||
t.equal(result.status, 0)
|
||||
|
||||
t.equal(normalizeNewline(result.stdout.toString()), ' ' + stripIndents`
|
||||
Package Current Wanted Latest
|
||||
project-1 is-positive 1.0.0 1.0.0 3.1.0
|
||||
` + '\n')
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user