@pnpm/deps.inspection.commands 1100.0.0 → 1100.1.1
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/lib/docs/index.d.ts +6 -0
- package/lib/docs/index.js +44 -0
- package/lib/fetchPackageInfo.d.ts +13 -0
- package/lib/fetchPackageInfo.js +70 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/view/index.js +2 -66
- package/package.json +22 -20
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Config, type ConfigContext } from '@pnpm/config.reader';
|
|
2
|
+
export declare function rcOptionsTypes(): Record<string, unknown>;
|
|
3
|
+
export declare function cliOptionsTypes(): Record<string, unknown>;
|
|
4
|
+
export declare const commandNames: string[];
|
|
5
|
+
export declare function help(): string;
|
|
6
|
+
export declare function handler(opts: Config & ConfigContext, params: string[]): Promise<void>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { types as allTypes } from '@pnpm/config.reader';
|
|
2
|
+
import { PnpmError } from '@pnpm/error';
|
|
3
|
+
import open from 'open';
|
|
4
|
+
import { pick } from 'ramda';
|
|
5
|
+
import { renderHelp } from 'render-help';
|
|
6
|
+
import { fetchPackageInfo } from '../fetchPackageInfo.js';
|
|
7
|
+
export function rcOptionsTypes() {
|
|
8
|
+
return pick(['registry'], allTypes);
|
|
9
|
+
}
|
|
10
|
+
export function cliOptionsTypes() {
|
|
11
|
+
return rcOptionsTypes();
|
|
12
|
+
}
|
|
13
|
+
export const commandNames = ['docs', 'home'];
|
|
14
|
+
export function help() {
|
|
15
|
+
return renderHelp({
|
|
16
|
+
description: 'Open the documentation of a package.',
|
|
17
|
+
usages: [
|
|
18
|
+
'pnpm docs <package-name>',
|
|
19
|
+
'pnpm docs <package-name>@<version>',
|
|
20
|
+
'pnpm home <package-name>',
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export async function handler(opts, params) {
|
|
25
|
+
const packageSpec = params[0];
|
|
26
|
+
if (!packageSpec) {
|
|
27
|
+
throw new PnpmError('MISSING_PACKAGE_NAME', 'Package name is required. Usage: pnpm docs <package-name>');
|
|
28
|
+
}
|
|
29
|
+
const info = await fetchPackageInfo(opts, packageSpec);
|
|
30
|
+
const url = isHttpUrl(info.homepage) ? info.homepage : `https://npmx.dev/package/${info.name}`;
|
|
31
|
+
await open(url);
|
|
32
|
+
}
|
|
33
|
+
function isHttpUrl(value) {
|
|
34
|
+
if (typeof value !== 'string' || value === '')
|
|
35
|
+
return false;
|
|
36
|
+
try {
|
|
37
|
+
const { protocol } = new URL(value);
|
|
38
|
+
return protocol === 'http:' || protocol === 'https:';
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Config, ConfigContext } from '@pnpm/config.reader';
|
|
2
|
+
import type { PackageInRegistry } from '@pnpm/resolving.registry.types';
|
|
3
|
+
export type ExtendedPackageInfo = PackageInRegistry & {
|
|
4
|
+
author?: string;
|
|
5
|
+
repository?: string;
|
|
6
|
+
versions: string[];
|
|
7
|
+
versionsCount?: number;
|
|
8
|
+
depsCount?: number;
|
|
9
|
+
distTags: Record<string, string>;
|
|
10
|
+
'dist-tags': Record<string, string>;
|
|
11
|
+
time?: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
export declare function fetchPackageInfo(opts: Config & ConfigContext, packageSpec: string): Promise<ExtendedPackageInfo>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { pickRegistryForPackage } from '@pnpm/config.pick-registry-for-package';
|
|
2
|
+
import { PnpmError } from '@pnpm/error';
|
|
3
|
+
import { createGetAuthHeaderByURI } from '@pnpm/network.auth-header';
|
|
4
|
+
import { createFetchFromRegistry } from '@pnpm/network.fetch';
|
|
5
|
+
import npa from '@pnpm/npm-package-arg';
|
|
6
|
+
import { fetchMetadataFromFromRegistry, pickPackageFromMeta, pickVersionByVersionRange, } from '@pnpm/resolving.npm-resolver';
|
|
7
|
+
export async function fetchPackageInfo(opts, packageSpec) {
|
|
8
|
+
let parsed;
|
|
9
|
+
try {
|
|
10
|
+
parsed = npa(packageSpec);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
throw new PnpmError('INVALID_PACKAGE_NAME', `Invalid package name: "${packageSpec}"`);
|
|
14
|
+
}
|
|
15
|
+
if (!parsed.registry) {
|
|
16
|
+
throw new PnpmError('INVALID_PACKAGE_NAME', `Invalid package name: "${packageSpec}". This command only supports registry packages.`);
|
|
17
|
+
}
|
|
18
|
+
const subSpec = parsed.type === 'alias' ? parsed.subSpec : parsed;
|
|
19
|
+
const packageName = subSpec?.name;
|
|
20
|
+
if (!packageName) {
|
|
21
|
+
throw new PnpmError('INVALID_PACKAGE_NAME', `Invalid package name: "${packageSpec}"`);
|
|
22
|
+
}
|
|
23
|
+
const specType = (subSpec?.type ?? 'tag');
|
|
24
|
+
const spec = {
|
|
25
|
+
name: packageName,
|
|
26
|
+
fetchSpec: subSpec?.fetchSpec ?? 'latest',
|
|
27
|
+
type: specType,
|
|
28
|
+
};
|
|
29
|
+
const registry = pickRegistryForPackage(opts.registries, packageName);
|
|
30
|
+
const fetchFromRegistry = createFetchFromRegistry(opts);
|
|
31
|
+
const getAuthHeader = createGetAuthHeaderByURI(opts.configByUri ?? {}, opts.registries?.default);
|
|
32
|
+
const fetchResult = await fetchMetadataFromFromRegistry({
|
|
33
|
+
fetch: fetchFromRegistry,
|
|
34
|
+
retry: {
|
|
35
|
+
factor: opts.fetchRetryFactor,
|
|
36
|
+
maxTimeout: opts.fetchRetryMaxtimeout,
|
|
37
|
+
minTimeout: opts.fetchRetryMintimeout,
|
|
38
|
+
retries: opts.fetchRetries,
|
|
39
|
+
},
|
|
40
|
+
timeout: opts.fetchTimeout ?? 60000,
|
|
41
|
+
fetchWarnTimeoutMs: 10000,
|
|
42
|
+
}, packageName, {
|
|
43
|
+
registry,
|
|
44
|
+
authHeaderValue: getAuthHeader(registry),
|
|
45
|
+
fullMetadata: true,
|
|
46
|
+
});
|
|
47
|
+
if (fetchResult.notModified) {
|
|
48
|
+
throw new PnpmError('UNEXPECTED_304', `Unexpected 304 response for ${packageName}`);
|
|
49
|
+
}
|
|
50
|
+
const { meta: metadata } = fetchResult;
|
|
51
|
+
const data = pickPackageFromMeta(pickVersionByVersionRange, { preferredVersionSelectors: undefined }, spec, metadata);
|
|
52
|
+
if (!data) {
|
|
53
|
+
throw new PnpmError('PACKAGE_NOT_FOUND', `No matching version found for ${packageName}@${spec.fetchSpec}`);
|
|
54
|
+
}
|
|
55
|
+
const versions = metadata.versions ? Object.keys(metadata.versions) : [];
|
|
56
|
+
const depsCount = data.dependencies ? Object.keys(data.dependencies).length : 0;
|
|
57
|
+
const distTags = metadata['dist-tags'];
|
|
58
|
+
return {
|
|
59
|
+
...data,
|
|
60
|
+
author: typeof data.author === 'object' ? data.author.name : data.author,
|
|
61
|
+
repository: typeof data.repository === 'object' ? data.repository.url : data.repository,
|
|
62
|
+
versions,
|
|
63
|
+
versionsCount: versions.length > 0 ? versions.length : undefined,
|
|
64
|
+
depsCount: depsCount > 0 ? depsCount : undefined,
|
|
65
|
+
distTags,
|
|
66
|
+
'dist-tags': distTags,
|
|
67
|
+
time: metadata.time,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=fetchPackageInfo.js.map
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/view/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { pickRegistryForPackage } from '@pnpm/config.pick-registry-for-package';
|
|
2
1
|
import { types as allTypes } from '@pnpm/config.reader';
|
|
3
2
|
import { PnpmError } from '@pnpm/error';
|
|
4
|
-
import { createGetAuthHeaderByURI } from '@pnpm/network.auth-header';
|
|
5
|
-
import { createFetchFromRegistry } from '@pnpm/network.fetch';
|
|
6
|
-
import npa from '@pnpm/npm-package-arg';
|
|
7
|
-
import { fetchMetadataFromFromRegistry, pickPackageFromMeta, pickVersionByVersionRange, } from '@pnpm/resolving.npm-resolver';
|
|
8
3
|
import { pick } from 'ramda';
|
|
9
4
|
import { renderHelp } from 'render-help';
|
|
5
|
+
import { fetchPackageInfo } from '../fetchPackageInfo.js';
|
|
10
6
|
export function rcOptionsTypes() {
|
|
11
7
|
return pick(['registry'], allTypes);
|
|
12
8
|
}
|
|
@@ -44,67 +40,7 @@ export async function handler(opts, params) {
|
|
|
44
40
|
throw new PnpmError('MISSING_PACKAGE_NAME', 'Package name is required. Usage: pnpm view <package-name>');
|
|
45
41
|
}
|
|
46
42
|
const fields = params.slice(1);
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
parsed = npa(packageSpec);
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
throw new PnpmError('INVALID_PACKAGE_NAME', `Invalid package name: "${packageSpec}"`);
|
|
53
|
-
}
|
|
54
|
-
if (!parsed.registry) {
|
|
55
|
-
throw new PnpmError('INVALID_PACKAGE_NAME', `Invalid package name: "${packageSpec}". pnpm view only supports registry packages.`);
|
|
56
|
-
}
|
|
57
|
-
const subSpec = parsed.type === 'alias' ? parsed.subSpec : parsed;
|
|
58
|
-
const packageName = subSpec?.name;
|
|
59
|
-
if (!packageName) {
|
|
60
|
-
throw new PnpmError('INVALID_PACKAGE_NAME', `Invalid package name: "${packageSpec}"`);
|
|
61
|
-
}
|
|
62
|
-
const specType = (subSpec?.type ?? 'tag');
|
|
63
|
-
const spec = {
|
|
64
|
-
name: packageName,
|
|
65
|
-
fetchSpec: subSpec?.fetchSpec ?? 'latest',
|
|
66
|
-
type: specType,
|
|
67
|
-
};
|
|
68
|
-
const registry = pickRegistryForPackage(opts.registries, packageName);
|
|
69
|
-
const fetchFromRegistry = createFetchFromRegistry(opts);
|
|
70
|
-
const getAuthHeader = createGetAuthHeaderByURI(opts.configByUri ?? {}, opts.registries?.default);
|
|
71
|
-
const fetchResult = await fetchMetadataFromFromRegistry({
|
|
72
|
-
fetch: fetchFromRegistry,
|
|
73
|
-
retry: {
|
|
74
|
-
factor: opts.fetchRetryFactor,
|
|
75
|
-
maxTimeout: opts.fetchRetryMaxtimeout,
|
|
76
|
-
minTimeout: opts.fetchRetryMintimeout,
|
|
77
|
-
retries: opts.fetchRetries,
|
|
78
|
-
},
|
|
79
|
-
timeout: opts.fetchTimeout ?? 60000,
|
|
80
|
-
fetchWarnTimeoutMs: 10000,
|
|
81
|
-
}, packageName, {
|
|
82
|
-
registry,
|
|
83
|
-
authHeaderValue: getAuthHeader(registry),
|
|
84
|
-
fullMetadata: true,
|
|
85
|
-
});
|
|
86
|
-
if (fetchResult.notModified) {
|
|
87
|
-
throw new PnpmError('UNEXPECTED_304', `Unexpected 304 response for ${packageName}`);
|
|
88
|
-
}
|
|
89
|
-
const { meta: metadata } = fetchResult;
|
|
90
|
-
const data = pickPackageFromMeta(pickVersionByVersionRange, { preferredVersionSelectors: undefined }, spec, metadata);
|
|
91
|
-
if (!data) {
|
|
92
|
-
throw new PnpmError('PACKAGE_NOT_FOUND', `No matching version found for ${packageName}@${spec.fetchSpec}`);
|
|
93
|
-
}
|
|
94
|
-
const versions = metadata.versions ? Object.keys(metadata.versions) : [];
|
|
95
|
-
const depsCount = data.dependencies ? Object.keys(data.dependencies).length : 0;
|
|
96
|
-
const distTags = metadata['dist-tags'];
|
|
97
|
-
const info = {
|
|
98
|
-
...data,
|
|
99
|
-
author: typeof data.author === 'object' ? data.author.name : data.author,
|
|
100
|
-
repository: typeof data.repository === 'object' ? data.repository.url : data.repository,
|
|
101
|
-
versions,
|
|
102
|
-
versionsCount: versions.length > 0 ? versions.length : undefined,
|
|
103
|
-
depsCount: depsCount > 0 ? depsCount : undefined,
|
|
104
|
-
distTags,
|
|
105
|
-
'dist-tags': distTags,
|
|
106
|
-
time: metadata.time,
|
|
107
|
-
};
|
|
43
|
+
const info = await fetchPackageInfo(opts, packageSpec);
|
|
108
44
|
// If fields are specified, filter and return only those
|
|
109
45
|
if (fields.length > 0) {
|
|
110
46
|
const selectedFields = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/deps.inspection.commands",
|
|
3
|
-
"version": "1100.
|
|
3
|
+
"version": "1100.1.1",
|
|
4
4
|
"description": "The list, ll, why, and outdated commands of pnpm",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -29,28 +29,30 @@
|
|
|
29
29
|
"@pnpm/semver-diff": "^1.1.0",
|
|
30
30
|
"@zkochan/table": "^2.0.1",
|
|
31
31
|
"chalk": "^5.6.0",
|
|
32
|
+
"open": "^7.4.2",
|
|
32
33
|
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
33
34
|
"render-help": "^2.0.0",
|
|
34
35
|
"@pnpm/cli.command": "1100.0.0",
|
|
35
36
|
"@pnpm/cli.common-cli-options-help": "1100.0.0",
|
|
36
|
-
"@pnpm/cli.utils": "
|
|
37
|
+
"@pnpm/cli.utils": "1101.0.0",
|
|
37
38
|
"@pnpm/config.matcher": "1100.0.0",
|
|
38
|
-
"@pnpm/config.pick-registry-for-package": "1100.0.
|
|
39
|
-
"@pnpm/config.reader": "
|
|
40
|
-
"@pnpm/deps.inspection.
|
|
41
|
-
"@pnpm/deps.inspection.
|
|
39
|
+
"@pnpm/config.pick-registry-for-package": "1100.0.1",
|
|
40
|
+
"@pnpm/config.reader": "1101.0.0",
|
|
41
|
+
"@pnpm/deps.inspection.list": "1100.0.2",
|
|
42
|
+
"@pnpm/deps.inspection.outdated": "1100.0.2",
|
|
43
|
+
"@pnpm/deps.inspection.peers-checker": "1100.0.1",
|
|
44
|
+
"@pnpm/global.packages": "1100.0.1",
|
|
42
45
|
"@pnpm/error": "1100.0.0",
|
|
43
|
-
"@pnpm/
|
|
44
|
-
"@pnpm/
|
|
45
|
-
"@pnpm/
|
|
46
|
-
"@pnpm/
|
|
47
|
-
"@pnpm/network.
|
|
48
|
-
"@pnpm/
|
|
49
|
-
"@pnpm/resolving.npm-resolver": "1100.0.
|
|
46
|
+
"@pnpm/installing.modules-yaml": "1100.0.1",
|
|
47
|
+
"@pnpm/lockfile.fs": "1100.0.1",
|
|
48
|
+
"@pnpm/network.auth-header": "1100.0.1",
|
|
49
|
+
"@pnpm/global.commands": "1100.0.2",
|
|
50
|
+
"@pnpm/network.fetch": "1100.0.1",
|
|
51
|
+
"@pnpm/resolving.default-resolver": "1100.0.2",
|
|
52
|
+
"@pnpm/resolving.npm-resolver": "1100.0.1",
|
|
53
|
+
"@pnpm/resolving.registry.types": "1100.0.1",
|
|
50
54
|
"@pnpm/store.path": "1100.0.0",
|
|
51
|
-
"@pnpm/
|
|
52
|
-
"@pnpm/resolving.default-resolver": "1100.0.0",
|
|
53
|
-
"@pnpm/types": "1100.0.0"
|
|
55
|
+
"@pnpm/types": "1101.0.0"
|
|
54
56
|
},
|
|
55
57
|
"peerDependencies": {
|
|
56
58
|
"@pnpm/logger": ">=1001.0.0 <1002.0.0"
|
|
@@ -64,12 +66,12 @@
|
|
|
64
66
|
"symlink-dir": "^10.0.1",
|
|
65
67
|
"write-yaml-file": "^6.0.0",
|
|
66
68
|
"@pnpm/constants": "1100.0.0",
|
|
67
|
-
"@pnpm/deps.inspection.commands": "1100.
|
|
68
|
-
"@pnpm/installing.commands": "1100.0.0",
|
|
69
|
-
"@pnpm/prepare": "1100.0.0",
|
|
69
|
+
"@pnpm/deps.inspection.commands": "1100.1.1",
|
|
70
70
|
"@pnpm/test-fixtures": "1100.0.0",
|
|
71
|
+
"@pnpm/prepare": "1100.0.1",
|
|
72
|
+
"@pnpm/installing.commands": "1100.1.0",
|
|
71
73
|
"@pnpm/testing.command-defaults": "1100.0.0",
|
|
72
|
-
"@pnpm/workspace.projects-filter": "1100.0.
|
|
74
|
+
"@pnpm/workspace.projects-filter": "1100.0.2"
|
|
73
75
|
},
|
|
74
76
|
"engines": {
|
|
75
77
|
"node": ">=22.13"
|