Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pnpm outdated [-r] --json does not return all dependencies in workspace #7693

Open
2 of 4 tasks
jcao02 opened this issue Feb 22, 2024 · 0 comments
Open
2 of 4 tasks

Comments

@jcao02
Copy link

jcao02 commented Feb 22, 2024

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

8.15.1

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

  1. Install same dependency in two packages inside workspace. The two installs must have either: (1) different outdated versions or (2) same outdated version + different dependency type (dev or prod)
  2. Run pnpm -r outdated --json

Describe the Bug

The command is returning a single instance of the outdated dependency even though there is more than one. Take the following example where a workspace has two packages -- package-a and package-b -- installing vue@2.7.14, one inside dependencies and the other one inside devDependencies.

Running pnpm -r outdated vue, this is the output:

┌───────────┬─────────┬────────┬────────────────────────────────┐
│ Package   │ Current │ Latest │ Dependents                     │
├───────────┼─────────┼────────┼────────────────────────────────┤
│ vue       │ 2.7.14  │ 3.4.19 │ package-a                      │
├───────────┼─────────┼────────┼────────────────────────────────┤
│ vue (dev) │ 2.7.14  │ 3.4.19 │ package-b                      │
└───────────┴─────────┴────────┴────────────────────────────────┘

And running pnpm -r outdated vue --json, this is the output:

{
  "vue": {
    "current": "2.7.14",
    "latest": "3.4.19",
    "wanted": "2.7.14",
    "isDeprecated": false,
    "dependencyType": "devDependencies",
    "dependentPackages": [
      {
        "name": "package-b",
        "location": "/path/to/package-b"
      }
    ]
  }
}

Expected Behavior

I'd expect to have all the involved packages in the resulting JSON. Something like this:

{
  "vue@2.7.14": {
    "current": "2.7.14",
    "latest": "3.4.19",
    "wanted": "2.7.14",
    "isDeprecated": false,
    "dependencyType": "dependencies",
    "dependentPackages": [
      {
        "name": "package-a",
        "location": "/path/to/package-a"
      }
    ]
  },
  "vue@2.7.14 (dev)": {
    "current": "2.7.14",
    "latest": "3.4.19",
    "wanted": "2.7.14",
    "isDeprecated": false,
    "dependencyType": "devDependencies",
    "dependentPackages": [
      {
        "name": "package-b",
        "location": "/path/to/package-b"
      }
    ]
  }
}

The dependencyType and current version need to be taken into account in the JSON structure. Another alternative would be to use collections instead of objects:

{
  "vue": [
    {
      "current": "2.7.14",
      "latest": "3.4.19",
      "wanted": "2.7.14",
      "isDeprecated": false,
      "dependencyType": "dependencies",
      "dependentPackages": [
        {
          "name": "package-a",
          "location": "/path/to/package-a"
        }
      ]
    },
    {
      "current": "2.7.14",
      "latest": "3.4.19",
      "wanted": "2.7.14",
      "isDeprecated": false,
      "dependencyType": "devDependencies",
      "dependentPackages": [
        {
          "name": "package-b",
          "location": "/path/to/package-b"
        }
      ]
    }
  ]
}

The fix should be done here

Which Node.js version are you using?

v20.9.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant