Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/loose-meteors-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@pnpm/deps.inspection.commands": patch
---

Update `view` command to show deprecation warning and available bins.
20 changes: 20 additions & 0 deletions deps/inspection/commands/src/view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,31 @@ export async function handler (
lines.push(chalk.underline.blue(info.homepage))
}

if (info.deprecated) {
lines.push('')
lines.push(`${chalk.red('DEPRECATED!')} - ${info.deprecated}`)
}

if (info.keywords && info.keywords.length > 0) {
lines.push('')
lines.push(`keywords: ${chalk.cyan(info.keywords.join(', '))}`)
}

if (info.bin) {
let bins: string[] = []
if (typeof info.bin === 'string') {
if (info.bin.length > 0 && info.name) {
bins = [info.name[0] === '@' ? info.name.slice(info.name.indexOf('/') + 1) : info.name]
}
Comment thread
dasa marked this conversation as resolved.
} else {
bins = Object.keys(info.bin)
}
Comment thread
dasa marked this conversation as resolved.
Comment thread
dasa marked this conversation as resolved.
if (bins.length > 0) {
lines.push('')
lines.push(`bin: ${chalk.cyan(bins.join(', '))}`)
}
}
Comment thread
dasa marked this conversation as resolved.
Comment thread
dasa marked this conversation as resolved.
Comment thread
dasa marked this conversation as resolved.

if (info.dist) {
lines.push('')
lines.push(chalk.bold('dist'))
Expand Down
15 changes: 15 additions & 0 deletions deps/inspection/commands/test/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ test('view: text output includes header with name@version', async () => {
expect(firstLine).toContain('[email protected]')
})

test('view: text output includes bin from object', async () => {
const result = await view.handler(VIEW_OPTIONS as unknown as Config & ConfigContext, ['@pnpm.e2e/[email protected]']) as string
expect(result).toMatch(/^bin: t/m)
})

test('view: text output includes bin from string', async () => {
const result = await view.handler(VIEW_OPTIONS as unknown as Config & ConfigContext, ['@pnpm.e2e/hello-world-js-bin']) as string
expect(result).toMatch(/^bin: hello-world-js-bin/m)
})

test('view: text output includes dist section', async () => {
const result = await view.handler(VIEW_OPTIONS as unknown as Config & ConfigContext, ['[email protected]']) as string
expect(result).toContain('.tarball:')
Expand All @@ -143,6 +153,11 @@ test('view: text output for package with dependencies shows deps count', async (
expect(firstLine).not.toContain('deps: none')
})

test('view: text output for deprecated package shows deprecation', async () => {
const result = await view.handler(VIEW_OPTIONS as unknown as Config & ConfigContext, ['@pnpm.e2e/[email protected]']) as string
expect(result).toMatch(/^DEPRECATED! - .+/m)
})
Comment thread
dasa marked this conversation as resolved.

test('view: text output for package without dependencies shows deps: none', async () => {
const result = await view.handler(VIEW_OPTIONS as unknown as Config & ConfigContext, ['[email protected]']) as string
const firstLine = result.split('\n')[0]
Expand Down
Loading