-
-
Notifications
You must be signed in to change notification settings - Fork 934
/
licenses.ts
106 lines (97 loc) · 2.6 KB
/
licenses.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import {
docsUrl,
readDepNameCompletions,
} from '@pnpm/cli-utils'
import { CompletionFunc } from '@pnpm/command'
import {
FILTERING,
OPTIONS,
UNIVERSAL_OPTIONS,
} from '@pnpm/common-cli-options-help'
import { types as allTypes } from '@pnpm/config'
import { PnpmError } from '@pnpm/error'
import pick from 'ramda/src/pick'
import renderHelp from 'render-help'
import { licensesList, LicensesCommandOptions } from './licensesList'
export function rcOptionsTypes () {
return {
...pick(
['dev', 'global-dir', 'global', 'json', 'long', 'optional', 'production'],
allTypes
),
compatible: Boolean,
table: Boolean,
}
}
export const cliOptionsTypes = () => ({
...rcOptionsTypes(),
recursive: Boolean,
})
export const shorthands = {
D: '--dev',
P: '--production',
}
export const commandNames = ['licenses']
export function help () {
return renderHelp({
description: `Check for licenses packages. The check can be limited to a subset of the installed packages by providing arguments (patterns are supported).
Examples:
pnpm licenses list
pnpm licenses list --long`,
descriptionLists: [
{
title: 'Options',
list: [
{
description:
'By default, details about the packages (such as a link to the repo) are not displayed. \
To display the details, pass this option.',
name: '--long',
},
{
description: 'Show information in JSON format',
name: '--json',
},
{
description: 'Check only "dependencies" and "optionalDependencies"',
name: '--prod',
shortAlias: '-P',
},
{
description: 'Check only "devDependencies"',
name: '--dev',
shortAlias: '-D',
},
{
description: 'Don\'t check "optionalDependencies"',
name: '--no-optional',
},
OPTIONS.globalDir,
...UNIVERSAL_OPTIONS,
],
},
FILTERING,
],
url: docsUrl('licenses'),
usages: ['pnpm licenses [options]'],
})
}
export const completion: CompletionFunc = async (cliOpts) => {
return readDepNameCompletions(cliOpts.dir as string)
}
export async function handler (
opts: LicensesCommandOptions,
params: string[] = []
) {
if (params.length === 0) {
throw new PnpmError('LICENCES_NO_SUBCOMMAND', 'Please specify the subcommand')
}
switch (params[0]) {
case 'list':
case 'ls':
return licensesList(opts)
default: {
throw new PnpmError('LICENSES_UNKNOWN_SUBCOMMAND', 'This subcommand is not known')
}
}
}