mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-02 03:02:49 -05:00
5
.changeset/olive-weeks-jam.md
Normal file
5
.changeset/olive-weeks-jam.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-outdated": patch
|
||||
---
|
||||
|
||||
`pnpm outdated --long` should print details about the outdated dependency.
|
||||
5
.changeset/stupid-kiwis-beg.md
Normal file
5
.changeset/stupid-kiwis-beg.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/outdated": minor
|
||||
---
|
||||
|
||||
`outdatedDepsOfProjects()` accepts a new option: `fullMetadata`. When `fullMetadata` is `true`, the full version of the package's latest manifest is returned.
|
||||
1
fixtures/has-2-outdated-deps/.gitignore
vendored
Normal file
1
fixtures/has-2-outdated-deps/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!node_modules
|
||||
1
fixtures/has-2-outdated-deps/.npmrc
Normal file
1
fixtures/has-2-outdated-deps/.npmrc
Normal file
@@ -0,0 +1 @@
|
||||
shared-workspace-lockfile=false
|
||||
18
fixtures/has-2-outdated-deps/node_modules/.modules.yaml
generated
vendored
Normal file
18
fixtures/has-2-outdated-deps/node_modules/.modules.yaml
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
hoistPattern:
|
||||
- '*'
|
||||
hoistedDependencies: {}
|
||||
included:
|
||||
dependencies: true
|
||||
devDependencies: true
|
||||
optionalDependencies: true
|
||||
layoutVersion: 4
|
||||
packageManager: pnpm@5.5.10
|
||||
pendingBuilds: []
|
||||
publicHoistPattern:
|
||||
- '@types/*'
|
||||
- '*eslint*'
|
||||
registries:
|
||||
default: 'https://registry.npmjs.org/'
|
||||
skipped: []
|
||||
storeDir: /home/zoltan/.pnpm-store/v3
|
||||
virtualStoreDir: .pnpm
|
||||
10
fixtures/has-2-outdated-deps/package.json
Normal file
10
fixtures/has-2-outdated-deps/package.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "has-2-outdated-deps",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"is-negative": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"is-positive": "^1.0.0"
|
||||
}
|
||||
}
|
||||
21
fixtures/has-2-outdated-deps/pnpm-lock.yaml
generated
Normal file
21
fixtures/has-2-outdated-deps/pnpm-lock.yaml
generated
Normal file
@@ -0,0 +1,21 @@
|
||||
dependencies:
|
||||
is-negative: 1.0.1
|
||||
devDependencies:
|
||||
is-positive: 1.0.0
|
||||
lockfileVersion: 5.1
|
||||
packages:
|
||||
/is-negative/1.0.1:
|
||||
dev: false
|
||||
engines:
|
||||
node: '>=0.10.0'
|
||||
resolution:
|
||||
integrity: sha1-3GuHKO69A8db+HYIftzVDpy1aZQ=
|
||||
/is-positive/1.0.0:
|
||||
dev: true
|
||||
engines:
|
||||
node: '>=0.10.0'
|
||||
resolution:
|
||||
integrity: sha1-iACYVrZKLx632LsBeUGEJK4EUss=
|
||||
specifiers:
|
||||
is-negative: ^1.0.0
|
||||
is-positive: ^1.0.0
|
||||
@@ -15,7 +15,7 @@ interface GetManifestOpts {
|
||||
|
||||
export type ManifestGetterOptions = Omit<ClientOptions, 'authConfig'>
|
||||
& GetManifestOpts
|
||||
& { rawConfig: Record<string, string> }
|
||||
& { fullMetadata: boolean, rawConfig: Record<string, string> }
|
||||
|
||||
export function createManifestGetter (
|
||||
opts: ManifestGetterOptions
|
||||
|
||||
@@ -17,10 +17,10 @@ import R = require('ramda')
|
||||
export default async function outdatedDepsOfProjects (
|
||||
pkgs: Array<{dir: string, manifest: ProjectManifest}>,
|
||||
args: string[],
|
||||
opts: Omit<ManifestGetterOptions, 'storeDir' | 'lockfileDir'> & {
|
||||
opts: Omit<ManifestGetterOptions, 'fullMetadata' | 'storeDir' | 'lockfileDir'> & {
|
||||
compatible?: boolean
|
||||
include: IncludedDependencies
|
||||
} & Partial<Pick<ManifestGetterOptions, 'storeDir' | 'lockfileDir'>>
|
||||
} & Partial<Pick<ManifestGetterOptions, 'fullMetadata' | 'storeDir' | 'lockfileDir'>>
|
||||
): Promise<OutdatedPackage[][]> {
|
||||
if (!opts.lockfileDir) {
|
||||
return R.unnest(await Promise.all(
|
||||
@@ -37,6 +37,7 @@ export default async function outdatedDepsOfProjects (
|
||||
const storeDir = await storePath(opts.dir, opts.storeDir)
|
||||
const getLatestManifest = createManifestGetter({
|
||||
...opts,
|
||||
fullMetadata: opts.fullMetadata === true,
|
||||
lockfileDir,
|
||||
storeDir,
|
||||
})
|
||||
|
||||
@@ -171,7 +171,11 @@ export async function handler (
|
||||
manifest: await readProjectManifestOnly(opts.dir, opts),
|
||||
},
|
||||
]
|
||||
const [outdatedPackages] = (await outdatedDepsOfProjects(packages, params, { ...opts, include }))
|
||||
const [outdatedPackages] = await outdatedDepsOfProjects(packages, params, {
|
||||
...opts,
|
||||
fullMetadata: opts.long,
|
||||
include,
|
||||
})
|
||||
|
||||
if (!outdatedPackages.length) return { output: '', exitCode: 0 }
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ export default async (
|
||||
opts: OutdatedCommandOptions & { include: IncludedDependencies }
|
||||
) => {
|
||||
const outdatedMap = {} as Record<string, OutdatedInWorkspace>
|
||||
const outdatedPackagesByProject = await outdatedDepsOfProjects(pkgs, params, opts)
|
||||
const outdatedPackagesByProject = await outdatedDepsOfProjects(pkgs, params, { ...opts, fullMetadata: opts.long })
|
||||
for (let i = 0; i < outdatedPackagesByProject.length; i++) {
|
||||
const { dir, manifest } = pkgs[i]
|
||||
outdatedPackagesByProject[i].forEach((outdatedPkg) => {
|
||||
|
||||
@@ -12,6 +12,7 @@ import test = require('tape')
|
||||
|
||||
const fixtures = path.join(__dirname, '../../../fixtures')
|
||||
const hasOutdatedDepsFixture = path.join(fixtures, 'has-outdated-deps')
|
||||
const has2OutdatedDepsFixture = path.join(fixtures, 'has-2-outdated-deps')
|
||||
const hasOutdatedDepsFixtureAndExternalLockfile = path.join(fixtures, 'has-outdated-deps-and-external-shrinkwrap', 'pkg')
|
||||
const hasNotOutdatedDepsFixture = path.join(fixtures, 'has-not-outdated-deps')
|
||||
const hasMajorOutdatedDepsFixture = path.join(fixtures, 'has-major-outdated-deps')
|
||||
@@ -66,6 +67,34 @@ test('pnpm outdated: show details', async (t) => {
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('pnpm outdated: show details (using the public registry to verify that full metadata is being requested)', async (t) => {
|
||||
tempDir(t)
|
||||
|
||||
await fs.mkdir(path.resolve('node_modules/.pnpm'), { recursive: true })
|
||||
await fs.copyFile(path.join(has2OutdatedDepsFixture, 'node_modules/.pnpm/lock.yaml'), path.resolve('node_modules/.pnpm/lock.yaml'))
|
||||
await fs.copyFile(path.join(has2OutdatedDepsFixture, 'package.json'), path.resolve('package.json'))
|
||||
|
||||
const { output, exitCode } = await outdated.handler({
|
||||
...OUTDATED_OPTIONS,
|
||||
dir: process.cwd(),
|
||||
long: true,
|
||||
rawConfig: { registry: 'https://registry.npmjs.org/' },
|
||||
registries: { default: 'https://registry.npmjs.org/' },
|
||||
})
|
||||
|
||||
t.equal(exitCode, 1)
|
||||
t.equal(stripAnsi(output), `\
|
||||
┌───────────────────┬─────────┬────────┬─────────────────────────────────────────────┐
|
||||
│ Package │ Current │ Latest │ Details │
|
||||
├───────────────────┼─────────┼────────┼─────────────────────────────────────────────┤
|
||||
│ is-negative │ 1.0.1 │ 2.1.0 │ https://github.com/kevva/is-negative#readme │
|
||||
├───────────────────┼─────────┼────────┼─────────────────────────────────────────────┤
|
||||
│ is-positive (dev) │ 1.0.0 │ 3.1.0 │ https://github.com/kevva/is-positive#readme │
|
||||
└───────────────────┴─────────┴────────┴─────────────────────────────────────────────┘
|
||||
`)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('pnpm outdated: showing only prod or dev dependencies', async (t) => {
|
||||
tempDir(t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user