@pnpm/deps.inspection.commands 1100.3.7 → 1100.4.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.
Files changed (2) hide show
  1. package/lib/view/index.js +36 -6
  2. package/package.json +26 -25
package/lib/view/index.js CHANGED
@@ -1,6 +1,8 @@
1
+ import path from 'node:path';
1
2
  import { types as allTypes } from '@pnpm/config.reader';
2
3
  import { PnpmError } from '@pnpm/error';
3
4
  import { formatTimeAgo } from '@pnpm/resolving.npm-resolver';
5
+ import { tryReadProjectManifest } from '@pnpm/workspace.project-manifest-reader';
4
6
  import chalk from 'chalk';
5
7
  import { pick } from 'ramda';
6
8
  import { renderHelp } from 'render-help';
@@ -17,11 +19,11 @@ export function cliOptionsTypes() {
17
19
  export const commandNames = ['view', 'info', 'show', 'v'];
18
20
  export function help() {
19
21
  return renderHelp({
20
- description: 'View package information from the registry without using npm CLI.',
22
+ description: 'View package information from the registry. If package name is omitted, searches upward for the nearest package manifest.',
21
23
  usages: [
22
- 'pnpm view <package-name>',
23
- 'pnpm view <package-name>@<version>',
24
- 'pnpm view <package-name> [<field>[.subfield]...]',
24
+ 'pnpm view [<package-name>]',
25
+ 'pnpm view [<package-name>@<version>]',
26
+ 'pnpm view [<package-name>] [<field>[.subfield]...]',
25
27
  ],
26
28
  descriptionLists: [
27
29
  {
@@ -37,9 +39,16 @@ export function help() {
37
39
  });
38
40
  }
39
41
  export async function handler(opts, params) {
40
- const packageSpec = params[0];
42
+ let packageSpec = params[0];
41
43
  if (!packageSpec) {
42
- throw new PnpmError('MISSING_PACKAGE_NAME', 'Package name is required. Usage: pnpm view <package-name>');
44
+ const nearestManifest = await findNearestProjectManifest(opts.dir ?? process.cwd(), opts);
45
+ if (!nearestManifest) {
46
+ throw new PnpmError('MISSING_PACKAGE_NAME', 'Package name is required. Usage: pnpm view [<package-name>]');
47
+ }
48
+ if (typeof nearestManifest.manifest.name !== 'string' || nearestManifest.manifest.name.length === 0) {
49
+ throw new PnpmError('INVALID_PACKAGE_JSON', `Invalid ${nearestManifest.fileName} at "${nearestManifest.projectDir}". The "name" field is required and must be a non-empty string.`);
50
+ }
51
+ packageSpec = nearestManifest.manifest.name;
43
52
  }
44
53
  const fields = params.slice(1);
45
54
  const info = await fetchPackageInfo(opts, packageSpec);
@@ -209,6 +218,27 @@ function getPublishedInfo(info) {
209
218
  }
210
219
  return `published ${chalk.cyan(timeAgo)}`;
211
220
  }
221
+ async function findNearestProjectManifest(startDir, _opts) {
222
+ try {
223
+ const result = await tryReadProjectManifest(startDir);
224
+ if (result.manifest != null) {
225
+ return {
226
+ manifest: result.manifest,
227
+ fileName: result.fileName,
228
+ projectDir: startDir,
229
+ };
230
+ }
231
+ }
232
+ catch (err) {
233
+ const message = err instanceof Error ? err.message : String(err);
234
+ throw new PnpmError('INVALID_PACKAGE_JSON', `Failed to read or parse project manifest in "${startDir}": ${message}`);
235
+ }
236
+ const parentDir = path.dirname(startDir);
237
+ if (parentDir === startDir) {
238
+ return null;
239
+ }
240
+ return findNearestProjectManifest(parentDir, _opts);
241
+ }
212
242
  /**
213
243
  * Retrieves the publisher name from package metadata.
214
244
  * Checks fields in order: _npmUser, maintainers, author.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/deps.inspection.commands",
3
- "version": "1100.3.7",
3
+ "version": "1100.4.1",
4
4
  "description": "The list, ll, why, and outdated commands of pnpm",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -10,9 +10,9 @@
10
10
  "funding": "https://opencollective.com/pnpm",
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/pnpm/pnpm/tree/main/deps/inspection/commands"
13
+ "url": "https://github.com/pnpm/pnpm/tree/main/pnpm11/deps/inspection/commands"
14
14
  },
15
- "homepage": "https://github.com/pnpm/pnpm/tree/main/deps/inspection/commands#readme",
15
+ "homepage": "https://github.com/pnpm/pnpm/tree/main/pnpm11/deps/inspection/commands#readme",
16
16
  "bugs": {
17
17
  "url": "https://github.com/pnpm/pnpm/issues"
18
18
  },
@@ -37,27 +37,28 @@
37
37
  "ramda": "npm:@pnpm/ramda@0.28.1",
38
38
  "render-help": "^2.0.0",
39
39
  "@pnpm/cli.command": "1100.0.1",
40
+ "@pnpm/cli.common-cli-options-help": "1100.0.2",
41
+ "@pnpm/cli.utils": "1101.0.13",
40
42
  "@pnpm/config.matcher": "1100.0.1",
41
- "@pnpm/cli.utils": "1101.0.12",
42
43
  "@pnpm/config.pick-registry-for-package": "1100.0.9",
43
- "@pnpm/config.reader": "1101.9.0",
44
- "@pnpm/cli.common-cli-options-help": "1100.0.2",
45
- "@pnpm/deps.inspection.list": "1100.0.18",
46
- "@pnpm/deps.inspection.outdated": "1100.1.8",
44
+ "@pnpm/config.reader": "1101.10.1",
45
+ "@pnpm/deps.inspection.list": "1100.0.20",
46
+ "@pnpm/deps.inspection.peers-checker": "1100.0.16",
47
+ "@pnpm/deps.inspection.outdated": "1100.1.10",
48
+ "@pnpm/error": "1100.0.1",
47
49
  "@pnpm/deps.inspection.peers-issues-renderer": "1100.0.6",
48
- "@pnpm/global.packages": "1100.0.8",
49
- "@pnpm/global.commands": "1100.0.28",
50
- "@pnpm/deps.inspection.peers-checker": "1100.0.14",
51
- "@pnpm/error": "1100.0.0",
52
- "@pnpm/network.auth-header": "1101.1.2",
50
+ "@pnpm/global.commands": "1100.0.30",
51
+ "@pnpm/global.packages": "1100.0.9",
53
52
  "@pnpm/installing.modules-yaml": "1100.0.9",
54
- "@pnpm/lockfile.fs": "1100.1.5",
55
- "@pnpm/network.fetch": "1100.1.3",
53
+ "@pnpm/network.auth-header": "1101.1.3",
54
+ "@pnpm/network.fetch": "1100.1.4",
55
+ "@pnpm/resolving.default-resolver": "1100.3.10",
56
+ "@pnpm/resolving.npm-resolver": "1102.1.0",
56
57
  "@pnpm/resolving.registry.types": "1100.1.3",
57
- "@pnpm/resolving.npm-resolver": "1102.0.0",
58
- "@pnpm/store.path": "1100.0.1",
58
+ "@pnpm/store.path": "1100.0.2",
59
59
  "@pnpm/types": "1101.3.2",
60
- "@pnpm/resolving.default-resolver": "1100.3.8"
60
+ "@pnpm/lockfile.fs": "1100.1.7",
61
+ "@pnpm/workspace.project-manifest-reader": "1100.0.14"
61
62
  },
62
63
  "peerDependencies": {
63
64
  "@pnpm/logger": "^1100.0.0"
@@ -70,14 +71,14 @@
70
71
  "execa": "npm:safe-execa@0.3.0",
71
72
  "symlink-dir": "^10.0.1",
72
73
  "write-yaml-file": "^6.0.0",
73
- "@pnpm/installing.commands": "1100.9.0",
74
- "@pnpm/deps.inspection.commands": "1100.3.7",
75
- "@pnpm/test-fixtures": "1100.0.0",
76
- "@pnpm/prepare": "1100.0.16",
74
+ "@pnpm/deps.inspection.commands": "1100.4.1",
75
+ "@pnpm/installing.commands": "1100.10.1",
77
76
  "@pnpm/constants": "1100.0.0",
78
- "@pnpm/testing.command-defaults": "1100.0.6",
79
- "@pnpm/workspace.projects-filter": "1100.0.21",
80
- "@pnpm/testing.registry-mock": "1100.0.6"
77
+ "@pnpm/prepare": "1100.0.17",
78
+ "@pnpm/test-fixtures": "1100.0.0",
79
+ "@pnpm/testing.command-defaults": "1100.0.7",
80
+ "@pnpm/testing.registry-mock": "1100.0.7",
81
+ "@pnpm/workspace.projects-filter": "1100.0.23"
81
82
  },
82
83
  "engines": {
83
84
  "node": ">=22.13"