@pnpm/deps.inspection.commands 1100.2.5 → 1100.3.0
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/fetchPackageInfo.d.ts +4 -1
- package/lib/fetchPackageInfo.js +0 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/repo/index.d.ts +8 -0
- package/lib/repo/index.js +95 -0
- package/package.json +14 -14
|
@@ -2,7 +2,10 @@ import type { Config, ConfigContext } from '@pnpm/config.reader';
|
|
|
2
2
|
import type { PackageInRegistry } from '@pnpm/resolving.registry.types';
|
|
3
3
|
export type ExtendedPackageInfo = PackageInRegistry & {
|
|
4
4
|
author?: string;
|
|
5
|
-
repository?: string
|
|
5
|
+
repository?: string | {
|
|
6
|
+
url?: string;
|
|
7
|
+
directory?: string;
|
|
8
|
+
};
|
|
6
9
|
versions: string[];
|
|
7
10
|
versionsCount?: number;
|
|
8
11
|
depsCount?: number;
|
package/lib/fetchPackageInfo.js
CHANGED
|
@@ -58,7 +58,6 @@ export async function fetchPackageInfo(opts, packageSpec) {
|
|
|
58
58
|
return {
|
|
59
59
|
...data,
|
|
60
60
|
author: typeof data.author === 'object' ? data.author.name : data.author,
|
|
61
|
-
repository: typeof data.repository === 'object' ? data.repository.url : data.repository,
|
|
62
61
|
versions,
|
|
63
62
|
versionsCount: versions.length > 0 ? versions.length : undefined,
|
|
64
63
|
depsCount: depsCount > 0 ? depsCount : undefined,
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -3,5 +3,6 @@ export * as docs from './docs/index.js';
|
|
|
3
3
|
export { list, ll, why } from './listing/index.js';
|
|
4
4
|
export { outdated } from './outdated/index.js';
|
|
5
5
|
export * as peers from './peers.js';
|
|
6
|
+
export * as repo from './repo/index.js';
|
|
6
7
|
export * as view from './view/index.js';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
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 & {
|
|
7
|
+
dir: string;
|
|
8
|
+
}, params: string[]): Promise<void>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { docsUrl, readProjectManifestOnly } from '@pnpm/cli.utils';
|
|
2
|
+
import { types as allTypes } from '@pnpm/config.reader';
|
|
3
|
+
import { PnpmError } from '@pnpm/error';
|
|
4
|
+
import HostedGit from 'hosted-git-info';
|
|
5
|
+
import open from 'open';
|
|
6
|
+
import { pick } from 'ramda';
|
|
7
|
+
import { renderHelp } from 'render-help';
|
|
8
|
+
import { fetchPackageInfo } from '../fetchPackageInfo.js';
|
|
9
|
+
export function rcOptionsTypes() {
|
|
10
|
+
return pick(['registry'], allTypes);
|
|
11
|
+
}
|
|
12
|
+
export function cliOptionsTypes() {
|
|
13
|
+
return rcOptionsTypes();
|
|
14
|
+
}
|
|
15
|
+
export const commandNames = ['repo'];
|
|
16
|
+
export function help() {
|
|
17
|
+
return renderHelp({
|
|
18
|
+
description: "Opens the URL of the package's repository in a browser.",
|
|
19
|
+
url: docsUrl('repo'),
|
|
20
|
+
usages: ['pnpm repo [<pkgname> [<pkgname> ...]]'],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export async function handler(opts, params) {
|
|
24
|
+
const urls = params.length === 0
|
|
25
|
+
? [await getRepoUrlFromCurrentProject(opts)]
|
|
26
|
+
: await Promise.all(params.map((spec) => getRepoUrlFromRegistry(opts, spec)));
|
|
27
|
+
for (const url of urls) {
|
|
28
|
+
// eslint-disable-next-line no-await-in-loop
|
|
29
|
+
await open(url);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function getRepoUrlFromCurrentProject(opts) {
|
|
33
|
+
const manifest = await readProjectManifestOnly(opts.dir, {
|
|
34
|
+
engineStrict: opts.engineStrict,
|
|
35
|
+
nodeVersion: opts.nodeVersion,
|
|
36
|
+
supportedArchitectures: opts.supportedArchitectures,
|
|
37
|
+
});
|
|
38
|
+
const url = pickRepoUrl(manifest.repository);
|
|
39
|
+
if (!url) {
|
|
40
|
+
throw new PnpmError('NO_REPO_URL', 'The current project does not have a repository URL. Add a "repository" field to its manifest.');
|
|
41
|
+
}
|
|
42
|
+
return url;
|
|
43
|
+
}
|
|
44
|
+
async function getRepoUrlFromRegistry(opts, packageSpec) {
|
|
45
|
+
const info = await fetchPackageInfo(opts, packageSpec);
|
|
46
|
+
const url = pickRepoUrl(info.repository);
|
|
47
|
+
if (!url) {
|
|
48
|
+
throw new PnpmError('NO_REPO_URL', `The package "${info.name}" does not have a repository URL.`);
|
|
49
|
+
}
|
|
50
|
+
return url;
|
|
51
|
+
}
|
|
52
|
+
function pickRepoUrl(repository) {
|
|
53
|
+
if (!repository)
|
|
54
|
+
return undefined;
|
|
55
|
+
const repoUrl = typeof repository === 'string' ? repository : repository.url;
|
|
56
|
+
if (!repoUrl)
|
|
57
|
+
return undefined;
|
|
58
|
+
const directory = typeof repository === 'object' ? repository.directory : undefined;
|
|
59
|
+
return repositoryToWebUrl(repoUrl, directory);
|
|
60
|
+
}
|
|
61
|
+
function repositoryToWebUrl(rawUrl, directory) {
|
|
62
|
+
const hosted = HostedGit.fromUrl(rawUrl);
|
|
63
|
+
if (hosted != null) {
|
|
64
|
+
const url = directory ? hosted.browse(directory) : hosted.browse();
|
|
65
|
+
if (url && isHttpUrl(url)) {
|
|
66
|
+
return url;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
let parsed;
|
|
70
|
+
try {
|
|
71
|
+
parsed = new URL(rawUrl.replace(/^git\+/, ''));
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:')
|
|
77
|
+
return undefined;
|
|
78
|
+
parsed.search = '';
|
|
79
|
+
parsed.hash = '';
|
|
80
|
+
parsed.pathname = parsed.pathname.replace(/\/+$/, '').replace(/\.git$/, '');
|
|
81
|
+
if (directory) {
|
|
82
|
+
parsed.pathname += `/tree/HEAD/${directory.replace(/^\//, '')}`;
|
|
83
|
+
}
|
|
84
|
+
return parsed.toString();
|
|
85
|
+
}
|
|
86
|
+
function isHttpUrl(value) {
|
|
87
|
+
try {
|
|
88
|
+
const { protocol } = new URL(value);
|
|
89
|
+
return protocol === 'http:' || protocol === 'https:';
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/deps.inspection.commands",
|
|
3
|
-
"version": "1100.
|
|
3
|
+
"version": "1100.3.0",
|
|
4
4
|
"description": "The list, ll, why, and outdated commands of pnpm",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
35
35
|
"render-help": "^2.0.0",
|
|
36
36
|
"@pnpm/cli.command": "1100.0.1",
|
|
37
|
+
"@pnpm/cli.utils": "1101.0.7",
|
|
37
38
|
"@pnpm/cli.common-cli-options-help": "1100.0.1",
|
|
38
|
-
"@pnpm/cli.utils": "1101.0.6",
|
|
39
39
|
"@pnpm/config.matcher": "1100.0.1",
|
|
40
40
|
"@pnpm/config.pick-registry-for-package": "1100.0.5",
|
|
41
|
-
"@pnpm/
|
|
42
|
-
"@pnpm/
|
|
43
|
-
"@pnpm/deps.inspection.outdated": "1100.1.
|
|
41
|
+
"@pnpm/deps.inspection.list": "1100.0.13",
|
|
42
|
+
"@pnpm/config.reader": "1101.4.0",
|
|
43
|
+
"@pnpm/deps.inspection.outdated": "1100.1.2",
|
|
44
44
|
"@pnpm/deps.inspection.peers-checker": "1100.0.10",
|
|
45
45
|
"@pnpm/deps.inspection.peers-issues-renderer": "1100.0.2",
|
|
46
46
|
"@pnpm/error": "1100.0.0",
|
|
47
|
-
"@pnpm/global.commands": "1100.0.
|
|
47
|
+
"@pnpm/global.commands": "1100.0.21",
|
|
48
48
|
"@pnpm/global.packages": "1100.0.4",
|
|
49
|
-
"@pnpm/installing.modules-yaml": "1100.0.5",
|
|
50
49
|
"@pnpm/lockfile.fs": "1100.1.1",
|
|
50
|
+
"@pnpm/installing.modules-yaml": "1100.0.5",
|
|
51
51
|
"@pnpm/network.auth-header": "1100.0.3",
|
|
52
52
|
"@pnpm/network.fetch": "1100.0.6",
|
|
53
|
-
"@pnpm/resolving.default-resolver": "1100.3.
|
|
54
|
-
"@pnpm/resolving.npm-resolver": "1101.3.
|
|
55
|
-
"@pnpm/resolving.registry.types": "1100.0.4",
|
|
53
|
+
"@pnpm/resolving.default-resolver": "1100.3.2",
|
|
54
|
+
"@pnpm/resolving.npm-resolver": "1101.3.2",
|
|
56
55
|
"@pnpm/store.path": "1100.0.1",
|
|
57
|
-
"@pnpm/types": "1101.1.1"
|
|
56
|
+
"@pnpm/types": "1101.1.1",
|
|
57
|
+
"@pnpm/resolving.registry.types": "1100.0.4"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@pnpm/logger": ">=1001.0.0 <1002.0.0"
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
"symlink-dir": "^10.0.1",
|
|
70
70
|
"write-yaml-file": "^6.0.0",
|
|
71
71
|
"@pnpm/constants": "1100.0.0",
|
|
72
|
-
"@pnpm/deps.inspection.commands": "1100.2.5",
|
|
73
|
-
"@pnpm/installing.commands": "1100.4.1",
|
|
74
72
|
"@pnpm/prepare": "1100.0.10",
|
|
73
|
+
"@pnpm/installing.commands": "1100.5.0",
|
|
74
|
+
"@pnpm/deps.inspection.commands": "1100.3.0",
|
|
75
75
|
"@pnpm/test-fixtures": "1100.0.0",
|
|
76
76
|
"@pnpm/testing.command-defaults": "1100.0.1",
|
|
77
|
-
"@pnpm/workspace.projects-filter": "1100.0.
|
|
77
|
+
"@pnpm/workspace.projects-filter": "1100.0.15"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": ">=22.13"
|