@vltpkg/cli-sdk 1.0.0-rc.3 → 1.0.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/access.d.ts +22 -0
- package/dist/commands/access.js +246 -0
- package/dist/commands/bugs.d.ts +17 -0
- package/dist/commands/bugs.js +163 -0
- package/dist/{esm/commands → commands}/build.d.ts +0 -1
- package/dist/{esm/commands → commands}/build.js +0 -1
- package/dist/{esm/commands → commands}/cache.d.ts +0 -1
- package/dist/{esm/commands → commands}/cache.js +0 -1
- package/dist/{esm/commands → commands}/ci.d.ts +0 -1
- package/dist/{esm/commands → commands}/ci.js +11 -3
- package/dist/{esm/commands → commands}/config.d.ts +0 -1
- package/dist/{esm/commands → commands}/config.js +6 -1
- package/dist/commands/create.d.ts +8 -0
- package/dist/commands/create.js +102 -0
- package/dist/commands/deprecate.d.ts +13 -0
- package/dist/commands/deprecate.js +139 -0
- package/dist/commands/dist-tag.d.ts +21 -0
- package/dist/commands/dist-tag.js +177 -0
- package/dist/{esm/commands → commands}/docs.d.ts +0 -1
- package/dist/{esm/commands → commands}/docs.js +2 -3
- package/dist/{esm/commands → commands}/exec-cache.d.ts +0 -1
- package/dist/{esm/commands → commands}/exec-cache.js +0 -1
- package/dist/{esm/commands → commands}/exec-local.d.ts +0 -1
- package/dist/{esm/commands → commands}/exec-local.js +23 -1
- package/dist/{esm/commands → commands}/exec.d.ts +0 -1
- package/dist/{esm/commands → commands}/exec.js +84 -10
- package/dist/{esm/commands → commands}/help.d.ts +0 -1
- package/dist/{esm/commands → commands}/help.js +5 -1
- package/dist/{esm/commands → commands}/init.d.ts +0 -1
- package/dist/{esm/commands → commands}/init.js +31 -10
- package/dist/{esm/commands → commands}/install/reporter.d.ts +0 -1
- package/dist/{esm/commands → commands}/install/reporter.js +0 -1
- package/dist/{esm/commands → commands}/install.d.ts +21 -3
- package/dist/commands/install.js +140 -0
- package/dist/{esm/commands → commands}/list.d.ts +4 -2
- package/dist/{esm/commands → commands}/list.js +8 -10
- package/dist/{esm/commands → commands}/login.d.ts +0 -1
- package/dist/{esm/commands → commands}/login.js +10 -1
- package/dist/{esm/commands/token.d.ts → commands/logout.d.ts} +0 -1
- package/dist/{esm/commands → commands}/logout.js +10 -1
- package/dist/{esm/commands → commands}/pack.d.ts +0 -1
- package/dist/{esm/commands → commands}/pack.js +90 -32
- package/dist/commands/ping.d.ts +17 -0
- package/dist/commands/ping.js +114 -0
- package/dist/{esm/commands → commands}/pkg.d.ts +0 -1
- package/dist/{esm/commands → commands}/pkg.js +27 -1
- package/dist/commands/profile.d.ts +13 -0
- package/dist/commands/profile.js +104 -0
- package/dist/{esm/commands → commands}/publish.d.ts +1 -2
- package/dist/{esm/commands → commands}/publish.js +63 -12
- package/dist/{esm/commands → commands}/query.d.ts +4 -2
- package/dist/{esm/commands → commands}/query.js +12 -10
- package/dist/commands/repo.d.ts +17 -0
- package/dist/commands/repo.js +157 -0
- package/dist/{esm/commands → commands}/run-exec.d.ts +0 -1
- package/dist/commands/run-exec.js +40 -0
- package/dist/{esm/commands → commands}/run.d.ts +0 -1
- package/dist/{esm/commands → commands}/run.js +27 -1
- package/dist/commands/token.d.ts +31 -0
- package/dist/commands/token.js +186 -0
- package/dist/{esm/commands → commands}/uninstall.d.ts +0 -1
- package/dist/{esm/commands → commands}/uninstall.js +16 -3
- package/dist/commands/unpublish.d.ts +15 -0
- package/dist/commands/unpublish.js +200 -0
- package/dist/{esm/commands → commands}/update.d.ts +0 -1
- package/dist/{esm/commands → commands}/update.js +6 -1
- package/dist/{esm/commands → commands}/version.d.ts +0 -1
- package/dist/{esm/commands → commands}/version.js +27 -1
- package/dist/commands/view.d.ts +22 -0
- package/dist/commands/view.js +334 -0
- package/dist/{esm/commands → commands}/whoami.d.ts +0 -1
- package/dist/{esm/commands → commands}/whoami.js +10 -1
- package/dist/{esm/config → config}/definition.d.ts +39 -19
- package/dist/{esm/config → config}/definition.js +74 -39
- package/dist/{esm/config → config}/index.d.ts +0 -1
- package/dist/{esm/config → config}/index.js +37 -2
- package/dist/{esm/config → config}/merge.d.ts +0 -1
- package/dist/{esm/config → config}/merge.js +0 -1
- package/dist/{esm/config → config}/usage.d.ts +0 -1
- package/dist/{esm/config → config}/usage.js +0 -1
- package/dist/{esm/custom-help.d.ts → custom-help.d.ts} +0 -1
- package/dist/{esm/custom-help.js → custom-help.js} +35 -9
- package/dist/{esm/exec-command.d.ts → exec-command.d.ts} +0 -1
- package/dist/{esm/exec-command.js → exec-command.js} +14 -8
- package/dist/{esm/index.d.ts → index.d.ts} +0 -1
- package/dist/{esm/index.js → index.js} +1 -2
- package/dist/{esm/load-command.d.ts → load-command.d.ts} +0 -1
- package/dist/{esm/load-command.js → load-command.js} +0 -1
- package/dist/mermaid-image-view.d.ts +18 -0
- package/dist/mermaid-image-view.js +36 -0
- package/dist/{esm/output.d.ts → output.d.ts} +2 -2
- package/dist/{esm/output.js → output.js} +55 -2
- package/dist/{esm/pack-tarball.d.ts → pack-tarball.d.ts} +15 -1
- package/dist/{esm/pack-tarball.js → pack-tarball.js} +133 -91
- package/dist/{esm/parse-add-remove-args.d.ts → parse-add-remove-args.d.ts} +9 -3
- package/dist/{esm/parse-add-remove-args.js → parse-add-remove-args.js} +43 -11
- package/dist/{esm/print-err.d.ts → print-err.d.ts} +0 -1
- package/dist/{esm/print-err.js → print-err.js} +18 -3
- package/dist/query-diff-files.d.ts +17 -0
- package/dist/query-diff-files.js +63 -0
- package/dist/{esm/query-host-contexts.d.ts → query-host-contexts.d.ts} +0 -1
- package/dist/{esm/query-host-contexts.js → query-host-contexts.js} +8 -7
- package/dist/{esm/read-password.d.ts → read-password.d.ts} +0 -1
- package/dist/{esm/read-password.js → read-password.js} +0 -1
- package/dist/read-project-folders.d.ts +17 -0
- package/dist/read-project-folders.js +100 -0
- package/dist/reload-config.d.ts +2 -0
- package/dist/reload-config.js +11 -0
- package/dist/render-mermaid.d.ts +22 -0
- package/dist/render-mermaid.js +68 -0
- package/dist/telemetry.d.ts +58 -0
- package/dist/telemetry.js +170 -0
- package/dist/{esm/view.d.ts → view.d.ts} +0 -1
- package/dist/{esm/view.js → view.js} +1 -2
- package/package.json +69 -83
- package/dist/esm/commands/build.d.ts.map +0 -1
- package/dist/esm/commands/build.js.map +0 -1
- package/dist/esm/commands/cache.d.ts.map +0 -1
- package/dist/esm/commands/cache.js.map +0 -1
- package/dist/esm/commands/ci.d.ts.map +0 -1
- package/dist/esm/commands/ci.js.map +0 -1
- package/dist/esm/commands/config.d.ts.map +0 -1
- package/dist/esm/commands/config.js.map +0 -1
- package/dist/esm/commands/docs.d.ts.map +0 -1
- package/dist/esm/commands/docs.js.map +0 -1
- package/dist/esm/commands/exec-cache.d.ts.map +0 -1
- package/dist/esm/commands/exec-cache.js.map +0 -1
- package/dist/esm/commands/exec-local.d.ts.map +0 -1
- package/dist/esm/commands/exec-local.js.map +0 -1
- package/dist/esm/commands/exec.d.ts.map +0 -1
- package/dist/esm/commands/exec.js.map +0 -1
- package/dist/esm/commands/help.d.ts.map +0 -1
- package/dist/esm/commands/help.js.map +0 -1
- package/dist/esm/commands/init.d.ts.map +0 -1
- package/dist/esm/commands/init.js.map +0 -1
- package/dist/esm/commands/install/reporter.d.ts.map +0 -1
- package/dist/esm/commands/install/reporter.js.map +0 -1
- package/dist/esm/commands/install.d.ts.map +0 -1
- package/dist/esm/commands/install.js +0 -45
- package/dist/esm/commands/install.js.map +0 -1
- package/dist/esm/commands/list.d.ts.map +0 -1
- package/dist/esm/commands/list.js.map +0 -1
- package/dist/esm/commands/login.d.ts.map +0 -1
- package/dist/esm/commands/login.js.map +0 -1
- package/dist/esm/commands/logout.d.ts +0 -4
- package/dist/esm/commands/logout.d.ts.map +0 -1
- package/dist/esm/commands/logout.js.map +0 -1
- package/dist/esm/commands/pack.d.ts.map +0 -1
- package/dist/esm/commands/pack.js.map +0 -1
- package/dist/esm/commands/pkg.d.ts.map +0 -1
- package/dist/esm/commands/pkg.js.map +0 -1
- package/dist/esm/commands/publish.d.ts.map +0 -1
- package/dist/esm/commands/publish.js.map +0 -1
- package/dist/esm/commands/query.d.ts.map +0 -1
- package/dist/esm/commands/query.js.map +0 -1
- package/dist/esm/commands/run-exec.d.ts.map +0 -1
- package/dist/esm/commands/run-exec.js +0 -14
- package/dist/esm/commands/run-exec.js.map +0 -1
- package/dist/esm/commands/run.d.ts.map +0 -1
- package/dist/esm/commands/run.js.map +0 -1
- package/dist/esm/commands/serve.d.ts +0 -14
- package/dist/esm/commands/serve.d.ts.map +0 -1
- package/dist/esm/commands/serve.js +0 -103
- package/dist/esm/commands/serve.js.map +0 -1
- package/dist/esm/commands/token.d.ts.map +0 -1
- package/dist/esm/commands/token.js +0 -30
- package/dist/esm/commands/token.js.map +0 -1
- package/dist/esm/commands/uninstall.d.ts.map +0 -1
- package/dist/esm/commands/uninstall.js.map +0 -1
- package/dist/esm/commands/update.d.ts.map +0 -1
- package/dist/esm/commands/update.js.map +0 -1
- package/dist/esm/commands/version.d.ts.map +0 -1
- package/dist/esm/commands/version.js.map +0 -1
- package/dist/esm/commands/whoami.d.ts.map +0 -1
- package/dist/esm/commands/whoami.js.map +0 -1
- package/dist/esm/config/definition.d.ts.map +0 -1
- package/dist/esm/config/definition.js.map +0 -1
- package/dist/esm/config/index.d.ts.map +0 -1
- package/dist/esm/config/index.js.map +0 -1
- package/dist/esm/config/merge.d.ts.map +0 -1
- package/dist/esm/config/merge.js.map +0 -1
- package/dist/esm/config/usage.d.ts.map +0 -1
- package/dist/esm/config/usage.js.map +0 -1
- package/dist/esm/custom-help.d.ts.map +0 -1
- package/dist/esm/custom-help.js.map +0 -1
- package/dist/esm/exec-command.d.ts.map +0 -1
- package/dist/esm/exec-command.js.map +0 -1
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/load-command.d.ts.map +0 -1
- package/dist/esm/load-command.js.map +0 -1
- package/dist/esm/output.d.ts.map +0 -1
- package/dist/esm/output.js.map +0 -1
- package/dist/esm/pack-tarball.d.ts.map +0 -1
- package/dist/esm/pack-tarball.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/parse-add-remove-args.d.ts.map +0 -1
- package/dist/esm/parse-add-remove-args.js.map +0 -1
- package/dist/esm/print-err.d.ts.map +0 -1
- package/dist/esm/print-err.js.map +0 -1
- package/dist/esm/query-host-contexts.d.ts.map +0 -1
- package/dist/esm/query-host-contexts.js.map +0 -1
- package/dist/esm/read-password.d.ts.map +0 -1
- package/dist/esm/read-password.js.map +0 -1
- package/dist/esm/start-gui.d.ts +0 -10
- package/dist/esm/start-gui.d.ts.map +0 -1
- package/dist/esm/start-gui.js +0 -60
- package/dist/esm/start-gui.js.map +0 -1
- package/dist/esm/view.d.ts.map +0 -1
- package/dist/esm/view.js.map +0 -1
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import * as dotProp from '@vltpkg/dot-prop';
|
|
2
|
+
import { error } from '@vltpkg/error-cause';
|
|
3
|
+
import { PackageInfoClient } from '@vltpkg/package-info';
|
|
4
|
+
import { SecurityArchive } from '@vltpkg/security-archive';
|
|
5
|
+
import { Spec } from '@vltpkg/spec';
|
|
6
|
+
import { joinDepIDTuple } from '@vltpkg/dep-id';
|
|
7
|
+
import { commandUsage } from "../config/usage.js";
|
|
8
|
+
export const usage = () => commandUsage({
|
|
9
|
+
command: 'view',
|
|
10
|
+
usage: [
|
|
11
|
+
'<pkg>[@<version>] [<field>]',
|
|
12
|
+
'<pkg>[@<version>] [--view=human | json]',
|
|
13
|
+
],
|
|
14
|
+
description: `View registry information about a package.
|
|
15
|
+
|
|
16
|
+
Fetches and displays packument and manifest data for a given
|
|
17
|
+
package from the registry.
|
|
18
|
+
|
|
19
|
+
When a specific field is provided, only that field value is
|
|
20
|
+
displayed. Use dot-prop syntax to access nested fields
|
|
21
|
+
(e.g., \`dist-tags.latest\`, \`dependencies.lodash\`).
|
|
22
|
+
|
|
23
|
+
Security data from the vlt security archive is shown when
|
|
24
|
+
available, including scores and alerts.`,
|
|
25
|
+
examples: {
|
|
26
|
+
express: {
|
|
27
|
+
description: 'View info about the latest version of express',
|
|
28
|
+
},
|
|
29
|
+
'express@4.18.2': {
|
|
30
|
+
description: 'View info about a specific version',
|
|
31
|
+
},
|
|
32
|
+
'express versions': {
|
|
33
|
+
description: 'List all published versions',
|
|
34
|
+
},
|
|
35
|
+
'express dist-tags': {
|
|
36
|
+
description: 'Show all dist-tags',
|
|
37
|
+
},
|
|
38
|
+
'express dependencies': {
|
|
39
|
+
description: 'Show dependencies of the latest version',
|
|
40
|
+
},
|
|
41
|
+
'express dist-tags.latest': {
|
|
42
|
+
description: 'Show the latest dist-tag value',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
options: {
|
|
46
|
+
view: {
|
|
47
|
+
value: '[human | json]',
|
|
48
|
+
description: 'Output format. Defaults to human-readable or json if no tty.',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
const formatScore = (score) => `${Math.round(score * 100)}/100`;
|
|
53
|
+
const formatAlertSeverity = (severity) => {
|
|
54
|
+
switch (severity) {
|
|
55
|
+
case 'critical':
|
|
56
|
+
return '[CRITICAL]';
|
|
57
|
+
case 'high':
|
|
58
|
+
return '[HIGH]';
|
|
59
|
+
case 'medium':
|
|
60
|
+
return '[MEDIUM]';
|
|
61
|
+
case 'low':
|
|
62
|
+
return '[LOW]';
|
|
63
|
+
/* c8 ignore next 2 */
|
|
64
|
+
default:
|
|
65
|
+
return `[${String(severity).toUpperCase()}]`;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const formatSecurity = (report) => {
|
|
69
|
+
const lines = [];
|
|
70
|
+
const { score, alerts } = report;
|
|
71
|
+
lines.push('');
|
|
72
|
+
lines.push('security:');
|
|
73
|
+
lines.push(` score: ${formatScore(score.overall)}`);
|
|
74
|
+
lines.push(` license: ${formatScore(score.license)}`);
|
|
75
|
+
lines.push(` maintenance: ${formatScore(score.maintenance)}`);
|
|
76
|
+
lines.push(` quality: ${formatScore(score.quality)}`);
|
|
77
|
+
lines.push(` supply chain: ${formatScore(score.supplyChain)}`);
|
|
78
|
+
lines.push(` vulnerability: ${formatScore(score.vulnerability)}`);
|
|
79
|
+
if (alerts.length > 0) {
|
|
80
|
+
lines.push(` alerts: ${alerts.length}`);
|
|
81
|
+
for (const alert of alerts) {
|
|
82
|
+
lines.push(` ${formatAlertSeverity(alert.severity)} ${alert.type}: ${alert.key} (${alert.category})`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
lines.push(' alerts: none');
|
|
87
|
+
}
|
|
88
|
+
return lines.join('\n');
|
|
89
|
+
};
|
|
90
|
+
const formatDependencyCount = (manifest) => {
|
|
91
|
+
const lines = [];
|
|
92
|
+
const deps = Object.keys(manifest.dependencies ?? {}).length;
|
|
93
|
+
const devDeps = Object.keys(manifest.devDependencies ?? {}).length;
|
|
94
|
+
const optDeps = Object.keys(manifest.optionalDependencies ?? {}).length;
|
|
95
|
+
const peerDeps = Object.keys(manifest.peerDependencies ?? {}).length;
|
|
96
|
+
const parts = [];
|
|
97
|
+
if (deps > 0)
|
|
98
|
+
parts.push(`${deps} dependencies`);
|
|
99
|
+
if (devDeps > 0)
|
|
100
|
+
parts.push(`${devDeps} dev`);
|
|
101
|
+
if (optDeps > 0)
|
|
102
|
+
parts.push(`${optDeps} optional`);
|
|
103
|
+
if (peerDeps > 0)
|
|
104
|
+
parts.push(`${peerDeps} peer`);
|
|
105
|
+
if (parts.length > 0) {
|
|
106
|
+
lines.push(`deps: ${parts.join(', ')}`);
|
|
107
|
+
}
|
|
108
|
+
return lines;
|
|
109
|
+
};
|
|
110
|
+
const formatHuman = (result) => {
|
|
111
|
+
const { packument, manifest, security } = result;
|
|
112
|
+
const lines = [];
|
|
113
|
+
// Name and version
|
|
114
|
+
const name = manifest.name ?? packument.name;
|
|
115
|
+
const version = manifest.version ?? '';
|
|
116
|
+
lines.push(`${name}@${version}`);
|
|
117
|
+
// Description
|
|
118
|
+
if (manifest.description) {
|
|
119
|
+
lines.push(manifest.description);
|
|
120
|
+
}
|
|
121
|
+
lines.push('');
|
|
122
|
+
// License
|
|
123
|
+
if (manifest.license) {
|
|
124
|
+
lines.push(`license: ${manifest.license}`);
|
|
125
|
+
}
|
|
126
|
+
// Homepage
|
|
127
|
+
if (manifest.homepage) {
|
|
128
|
+
lines.push(`homepage: ${manifest.homepage}`);
|
|
129
|
+
}
|
|
130
|
+
// Repository
|
|
131
|
+
if (manifest.repository) {
|
|
132
|
+
const repo = typeof manifest.repository === 'string' ?
|
|
133
|
+
manifest.repository
|
|
134
|
+
: manifest.repository.url;
|
|
135
|
+
if (repo) {
|
|
136
|
+
lines.push(`repository: ${repo}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Author
|
|
140
|
+
if (manifest.author) {
|
|
141
|
+
const author = typeof manifest.author === 'string' ?
|
|
142
|
+
manifest.author
|
|
143
|
+
: manifest.author.name;
|
|
144
|
+
if (author) {
|
|
145
|
+
lines.push(`author: ${author}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// Keywords
|
|
149
|
+
if (manifest.keywords) {
|
|
150
|
+
const kw = Array.isArray(manifest.keywords) ?
|
|
151
|
+
manifest.keywords
|
|
152
|
+
: [manifest.keywords];
|
|
153
|
+
if (kw.length > 0) {
|
|
154
|
+
lines.push(`keywords: ${kw.join(', ')}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Dist-tags
|
|
158
|
+
const tagEntries = Object.entries(packument['dist-tags']);
|
|
159
|
+
if (tagEntries.length > 0) {
|
|
160
|
+
lines.push('');
|
|
161
|
+
lines.push('dist-tags:');
|
|
162
|
+
for (const [tag, ver] of tagEntries) {
|
|
163
|
+
lines.push(` ${tag}: ${ver}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Dependencies count
|
|
167
|
+
const depLines = formatDependencyCount(manifest);
|
|
168
|
+
if (depLines.length > 0) {
|
|
169
|
+
lines.push('');
|
|
170
|
+
lines.push(...depLines);
|
|
171
|
+
}
|
|
172
|
+
// Maintainers
|
|
173
|
+
if (packument.maintainers && packument.maintainers.length > 0) {
|
|
174
|
+
lines.push('');
|
|
175
|
+
lines.push('maintainers:');
|
|
176
|
+
for (const m of packument.maintainers) {
|
|
177
|
+
const mName = typeof m === 'string' ? m : m.name;
|
|
178
|
+
lines.push(` - ${mName}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Published time
|
|
182
|
+
if (packument.time && version && packument.time[version]) {
|
|
183
|
+
lines.push('');
|
|
184
|
+
lines.push(`published: ${packument.time[version]}`);
|
|
185
|
+
}
|
|
186
|
+
// Security info
|
|
187
|
+
if (security) {
|
|
188
|
+
lines.push(formatSecurity(security));
|
|
189
|
+
}
|
|
190
|
+
// Versions count
|
|
191
|
+
const versionCount = Object.keys(packument.versions).length;
|
|
192
|
+
if (versionCount > 0) {
|
|
193
|
+
lines.push('');
|
|
194
|
+
lines.push(`versions: ${versionCount} total`);
|
|
195
|
+
}
|
|
196
|
+
return lines.join('\n');
|
|
197
|
+
};
|
|
198
|
+
export const views = {
|
|
199
|
+
human: (result, _options, _conf) => {
|
|
200
|
+
// Field access mode: just return the value
|
|
201
|
+
if (result.fieldPath !== undefined) {
|
|
202
|
+
const val = result.fieldValue;
|
|
203
|
+
if (Array.isArray(val)) {
|
|
204
|
+
return val.join('\n');
|
|
205
|
+
}
|
|
206
|
+
if (typeof val === 'object' && val !== null) {
|
|
207
|
+
return JSON.stringify(val, null, 2);
|
|
208
|
+
}
|
|
209
|
+
if (val === undefined || val === null)
|
|
210
|
+
return '';
|
|
211
|
+
return typeof val === 'string' ? val : JSON.stringify(val);
|
|
212
|
+
}
|
|
213
|
+
// Full view mode
|
|
214
|
+
return formatHuman(result);
|
|
215
|
+
},
|
|
216
|
+
json: (result, _options, _conf) => {
|
|
217
|
+
if (result.fieldPath !== undefined) {
|
|
218
|
+
return result.fieldValue;
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
...result.manifest,
|
|
222
|
+
'dist-tags': result.packument['dist-tags'],
|
|
223
|
+
time: result.packument.time,
|
|
224
|
+
maintainers: result.packument.maintainers,
|
|
225
|
+
...(result.security ? { security: result.security } : {}),
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Create a minimal NodeLike for SecurityArchive lookup.
|
|
231
|
+
* Only the fields used by SecurityArchive.start() are needed.
|
|
232
|
+
*/
|
|
233
|
+
const createFakeNode = (name, version) => ({
|
|
234
|
+
id: joinDepIDTuple(['registry', '', `${name}@${version}`]),
|
|
235
|
+
name,
|
|
236
|
+
version,
|
|
237
|
+
confused: false,
|
|
238
|
+
edgesIn: new Set(),
|
|
239
|
+
edgesOut: new Map(),
|
|
240
|
+
workspaces: undefined,
|
|
241
|
+
importer: false,
|
|
242
|
+
mainImporter: false,
|
|
243
|
+
projectRoot: '',
|
|
244
|
+
dev: false,
|
|
245
|
+
optional: false,
|
|
246
|
+
graph: {},
|
|
247
|
+
options: {},
|
|
248
|
+
/* c8 ignore next 5 - stub methods for NodeLike interface */
|
|
249
|
+
toJSON: () => ({}),
|
|
250
|
+
toString: () => `${name}@${version}`,
|
|
251
|
+
setResolved: () => { },
|
|
252
|
+
setConfusedManifest: () => { },
|
|
253
|
+
maybeSetConfusedManifest: () => { },
|
|
254
|
+
});
|
|
255
|
+
/**
|
|
256
|
+
* Lookup fields from a combined packument+manifest view.
|
|
257
|
+
*
|
|
258
|
+
* The lookup searches in this order:
|
|
259
|
+
* 1. Top-level packument fields (name, dist-tags, versions, time,
|
|
260
|
+
* readme, maintainers)
|
|
261
|
+
* 2. Manifest fields for the resolved version
|
|
262
|
+
* 3. Security data (security.score, security.alerts)
|
|
263
|
+
*/
|
|
264
|
+
const lookupField = (result, path) => {
|
|
265
|
+
// Special handling for packument-level fields
|
|
266
|
+
const packumentFields = [
|
|
267
|
+
'dist-tags',
|
|
268
|
+
'versions',
|
|
269
|
+
'time',
|
|
270
|
+
'readme',
|
|
271
|
+
'maintainers',
|
|
272
|
+
'modified',
|
|
273
|
+
'contributors',
|
|
274
|
+
];
|
|
275
|
+
/* c8 ignore next - split always returns at least one element */
|
|
276
|
+
const topLevel = path.split('.')[0] ?? path;
|
|
277
|
+
if (packumentFields.includes(topLevel)) {
|
|
278
|
+
return dotProp.get(result.packument, path);
|
|
279
|
+
}
|
|
280
|
+
// Check security namespace
|
|
281
|
+
if (topLevel === 'security' && result.security) {
|
|
282
|
+
const subPath = path.slice('security.'.length);
|
|
283
|
+
if (subPath === '' || path === 'security') {
|
|
284
|
+
return result.security;
|
|
285
|
+
}
|
|
286
|
+
return dotProp.get(result.security, subPath);
|
|
287
|
+
}
|
|
288
|
+
// Default: look up in manifest
|
|
289
|
+
return dotProp.get(result.manifest, path);
|
|
290
|
+
};
|
|
291
|
+
export const command = async (conf) => {
|
|
292
|
+
const specArg = conf.positionals[0];
|
|
293
|
+
if (!specArg) {
|
|
294
|
+
throw error('view requires a package spec argument', {
|
|
295
|
+
code: 'EUSAGE',
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
const fieldPath = conf.positionals[1];
|
|
299
|
+
const spec = Spec.parseArgs(specArg, conf.options);
|
|
300
|
+
const pic = new PackageInfoClient(conf.options);
|
|
301
|
+
// Fetch the packument and resolved manifest
|
|
302
|
+
const [packument, resolvedManifest] = await Promise.all([
|
|
303
|
+
pic.packument(spec),
|
|
304
|
+
pic.manifest(spec),
|
|
305
|
+
]);
|
|
306
|
+
const manifest = resolvedManifest;
|
|
307
|
+
// Try to get security data for this package
|
|
308
|
+
let security;
|
|
309
|
+
const name = manifest.name ?? packument.name;
|
|
310
|
+
const version = manifest.version;
|
|
311
|
+
if (name && version) {
|
|
312
|
+
try {
|
|
313
|
+
const node = createFakeNode(name, version);
|
|
314
|
+
const archive = await SecurityArchive.start({
|
|
315
|
+
nodes: [node],
|
|
316
|
+
});
|
|
317
|
+
security = archive.get(node.id);
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
// Security data is optional, don't fail the command
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const result = {
|
|
324
|
+
packument,
|
|
325
|
+
manifest,
|
|
326
|
+
security,
|
|
327
|
+
};
|
|
328
|
+
// If a field path is provided, resolve it
|
|
329
|
+
if (fieldPath !== undefined) {
|
|
330
|
+
result.fieldPath = fieldPath;
|
|
331
|
+
result.fieldValue = lookupField(result, fieldPath);
|
|
332
|
+
}
|
|
333
|
+
return result;
|
|
334
|
+
};
|
|
@@ -5,6 +5,16 @@ export const usage = () => commandUsage({
|
|
|
5
5
|
usage: [''],
|
|
6
6
|
description: `Look up the username for the currently active token,
|
|
7
7
|
when logged into a registry.`,
|
|
8
|
+
options: {
|
|
9
|
+
registry: {
|
|
10
|
+
value: '<url>',
|
|
11
|
+
description: 'Registry URL to query for authenticated user info.',
|
|
12
|
+
},
|
|
13
|
+
identity: {
|
|
14
|
+
value: '<name>',
|
|
15
|
+
description: 'Identity namespace used to look up auth tokens.',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
8
18
|
});
|
|
9
19
|
export const views = {
|
|
10
20
|
human: r => r.username,
|
|
@@ -16,4 +26,3 @@ export const command = async (conf) => {
|
|
|
16
26
|
const { username } = response.json();
|
|
17
27
|
return { username };
|
|
18
28
|
};
|
|
19
|
-
//# sourceMappingURL=whoami.js.map
|
|
@@ -15,17 +15,23 @@ export declare const commands: {
|
|
|
15
15
|
readonly r: "run";
|
|
16
16
|
readonly 'run-script': "run";
|
|
17
17
|
readonly rx: "run-exec";
|
|
18
|
-
readonly s: "serve";
|
|
19
18
|
readonly x: "exec";
|
|
20
19
|
readonly xl: "exec-local";
|
|
21
20
|
readonly h: "help";
|
|
22
21
|
readonly '?': "help";
|
|
22
|
+
readonly info: "view";
|
|
23
23
|
readonly ls: "list";
|
|
24
|
+
readonly show: "view";
|
|
24
25
|
readonly xc: "exec-cache";
|
|
26
|
+
readonly access: "access";
|
|
27
|
+
readonly bugs: "bugs";
|
|
25
28
|
readonly build: "build";
|
|
26
29
|
readonly cache: "cache";
|
|
27
30
|
readonly ci: "ci";
|
|
28
31
|
readonly config: "config";
|
|
32
|
+
readonly create: "create";
|
|
33
|
+
readonly deprecate: "deprecate";
|
|
34
|
+
readonly 'dist-tag': "dist-tag";
|
|
29
35
|
readonly docs: "docs";
|
|
30
36
|
readonly exec: "exec";
|
|
31
37
|
readonly 'exec-local': "exec-local";
|
|
@@ -36,17 +42,21 @@ export declare const commands: {
|
|
|
36
42
|
readonly logout: "logout";
|
|
37
43
|
readonly list: "list";
|
|
38
44
|
readonly pack: "pack";
|
|
45
|
+
readonly ping: "ping";
|
|
39
46
|
readonly pkg: "pkg";
|
|
47
|
+
readonly profile: "profile";
|
|
40
48
|
readonly publish: "publish";
|
|
41
49
|
readonly query: "query";
|
|
50
|
+
readonly repo: "repo";
|
|
42
51
|
readonly 'run-exec': "run-exec";
|
|
43
52
|
readonly run: "run";
|
|
44
|
-
readonly serve: "serve";
|
|
45
53
|
readonly token: "token";
|
|
46
54
|
readonly uninstall: "uninstall";
|
|
55
|
+
readonly unpublish: "unpublish";
|
|
47
56
|
readonly update: "update";
|
|
48
57
|
readonly 'exec-cache': "exec-cache";
|
|
49
58
|
readonly version: "version";
|
|
59
|
+
readonly view: "view";
|
|
50
60
|
readonly whoami: "whoami";
|
|
51
61
|
};
|
|
52
62
|
/**
|
|
@@ -58,7 +68,7 @@ export declare const getCommand: (s?: string) => Commands[keyof Commands] | unde
|
|
|
58
68
|
/**
|
|
59
69
|
* Fields that are parsed as a set of key=value pairs
|
|
60
70
|
*/
|
|
61
|
-
export declare const recordFields: readonly ["git-hosts", "registries", "git-host-archives", "
|
|
71
|
+
export declare const recordFields: readonly ["git-hosts", "registries", "git-host-archives", "scoped-registries", "jsr-registries"];
|
|
62
72
|
export type RecordField = (typeof recordFields)[number];
|
|
63
73
|
export declare const isRecordField: (s: string) => s is RecordField;
|
|
64
74
|
export declare const definition: import("jackspeak").Jack<{
|
|
@@ -86,7 +96,7 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
86
96
|
hint: string;
|
|
87
97
|
description: string;
|
|
88
98
|
};
|
|
89
|
-
'
|
|
99
|
+
'scoped-registries': {
|
|
90
100
|
hint: string;
|
|
91
101
|
description: string;
|
|
92
102
|
};
|
|
@@ -106,7 +116,7 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
106
116
|
};
|
|
107
117
|
} & {
|
|
108
118
|
registries: import("jackspeak").ConfigOption<"string", true, readonly string[] | undefined>;
|
|
109
|
-
'
|
|
119
|
+
'scoped-registries': import("jackspeak").ConfigOption<"string", true, readonly string[] | undefined>;
|
|
110
120
|
'jsr-registries': import("jackspeak").ConfigOption<"string", true, readonly string[] | undefined>;
|
|
111
121
|
'git-hosts': import("jackspeak").ConfigOption<"string", true, readonly string[] | undefined>;
|
|
112
122
|
'git-host-archives': import("jackspeak").ConfigOption<"string", true, readonly string[] | undefined>;
|
|
@@ -132,6 +142,9 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
132
142
|
description: string;
|
|
133
143
|
default: NodeJS.Architecture;
|
|
134
144
|
};
|
|
145
|
+
libc: {
|
|
146
|
+
description: string;
|
|
147
|
+
};
|
|
135
148
|
'node-version': {
|
|
136
149
|
hint: string;
|
|
137
150
|
description: string;
|
|
@@ -143,6 +156,7 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
143
156
|
before: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
144
157
|
os: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
145
158
|
arch: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
159
|
+
libc: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
146
160
|
'node-version': import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
147
161
|
} & {
|
|
148
162
|
'git-shallow': {
|
|
@@ -199,7 +213,6 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
199
213
|
description: string;
|
|
200
214
|
};
|
|
201
215
|
'workspace-group': {
|
|
202
|
-
short: string;
|
|
203
216
|
description: string;
|
|
204
217
|
};
|
|
205
218
|
} & {
|
|
@@ -277,12 +290,19 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
277
290
|
};
|
|
278
291
|
} & {
|
|
279
292
|
package: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
293
|
+
} & {
|
|
294
|
+
call: {
|
|
295
|
+
hint: string;
|
|
296
|
+
description: string;
|
|
297
|
+
};
|
|
298
|
+
} & {
|
|
299
|
+
call: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
280
300
|
} & {
|
|
281
301
|
view: {
|
|
282
302
|
hint: string;
|
|
283
303
|
default: string;
|
|
284
304
|
description: string;
|
|
285
|
-
validOptions: readonly ["human", "json", "mermaid", "
|
|
305
|
+
validOptions: readonly ["human", "json", "mermaid", "svg", "png", "count", "inspect", "silent"];
|
|
286
306
|
};
|
|
287
307
|
} & {
|
|
288
308
|
view: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
@@ -326,6 +346,10 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
326
346
|
'dry-run': {
|
|
327
347
|
description: string;
|
|
328
348
|
};
|
|
349
|
+
force: {
|
|
350
|
+
short: string;
|
|
351
|
+
description: string;
|
|
352
|
+
};
|
|
329
353
|
'expect-lockfile': {
|
|
330
354
|
description: string;
|
|
331
355
|
};
|
|
@@ -337,6 +361,7 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
337
361
|
};
|
|
338
362
|
} & {
|
|
339
363
|
'dry-run': import("jackspeak").ConfigOption<"boolean", false, undefined>;
|
|
364
|
+
force: import("jackspeak").ConfigOption<"boolean", false, undefined>;
|
|
340
365
|
'expect-lockfile': import("jackspeak").ConfigOption<"boolean", false, undefined>;
|
|
341
366
|
'frozen-lockfile': import("jackspeak").ConfigOption<"boolean", false, undefined>;
|
|
342
367
|
'lockfile-only': import("jackspeak").ConfigOption<"boolean", false, undefined>;
|
|
@@ -351,7 +376,6 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
351
376
|
access: {
|
|
352
377
|
description: string;
|
|
353
378
|
validOptions: readonly ["public", "restricted"];
|
|
354
|
-
default: string;
|
|
355
379
|
};
|
|
356
380
|
} & {
|
|
357
381
|
access: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
@@ -363,19 +387,16 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
363
387
|
hint: string;
|
|
364
388
|
description: string;
|
|
365
389
|
};
|
|
366
|
-
port: {
|
|
367
|
-
hint: string;
|
|
368
|
-
description: string;
|
|
369
|
-
};
|
|
370
|
-
'registry-port': {
|
|
371
|
-
hint: string;
|
|
372
|
-
description: string;
|
|
373
|
-
};
|
|
374
390
|
} & {
|
|
375
391
|
otp: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
376
392
|
'publish-directory': import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
377
|
-
|
|
378
|
-
|
|
393
|
+
} & {
|
|
394
|
+
telemetry: {
|
|
395
|
+
description: string;
|
|
396
|
+
default: true;
|
|
397
|
+
};
|
|
398
|
+
} & {
|
|
399
|
+
telemetry: import("jackspeak").ConfigOption<"boolean", false, undefined>;
|
|
379
400
|
} & {
|
|
380
401
|
yes: {
|
|
381
402
|
short: string;
|
|
@@ -401,4 +422,3 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
401
422
|
}>;
|
|
402
423
|
export declare const getSortedCliOptions: () => string[];
|
|
403
424
|
export declare const getSortedKeys: () => string[];
|
|
404
|
-
//# sourceMappingURL=definition.d.ts.map
|