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

[query] need a descendant operator that can specify type #614

Open
Tracked by #345
lukekarrys opened this issue Dec 15, 2022 · 3 comments
Open
Tracked by #345

[query] need a descendant operator that can specify type #614

lukekarrys opened this issue Dec 15, 2022 · 3 comments

Comments

@lukekarrys
Copy link
Contributor

Problem Statement

In the npm/cli repo the following query should return an empty set since none of the direct dependents are .dev deps:

npm query ':root > #npm-package-arg.dev'
# should also apply to this
node . query ':root > .dev > #npm-package-arg'

Current Behavior

In the current implementation both :root and .dev are collected separately so it returns:

[
  {
    "name": "npm-package-arg",
    "version": "10.1.0",
    "location": "node_modules/npm-package-arg",
    "path": "/Users/lukekarrys/projects/npm/cli/node_modules/npm-package-arg",
    "from": [
      "node_modules/init-package-json",
      "node_modules/npm-pick-manifest",
      "node_modules/npm-registry-fetch",
      "node_modules/pacote",
      "node_modules/@npmcli/template-oss",
      "mock-registry",
      "workspaces/libnpmexec",
      "workspaces/libnpmaccess",
      "workspaces/libnpmdiff",
      "workspaces/libnpmpack",
      "workspaces/libnpmpublish",
      "workspaces/arborist",
      ""
    ],
    "to": [
      "node_modules/hosted-git-info",
      "node_modules/proc-log",
      "node_modules/semver",
      "node_modules/validate-npm-package-name"
    ],
    "dev": false,
    "inBundle": true,
    "deduped": false,
    "overridden": false,
    "queryContext": {}
  }
]

Expected Behavior

It should return [] since npm-package-arg is only a direct .prod dependency

@wraithgar
Copy link
Member

This seems like a docs/education issue. .dev does not mean "In the devDependencies of something in the current set" it means "It is in the tree because of something in the root's devDependencies"

It seems what you are trying to query is all of the entries in devDependencies?

@wraithgar
Copy link
Member

there's some improvement to be made for the .dev selector in general i think. we don't have a way to get only direct devDependencies and we also don't have a way to get every node that exists exclusively as a devdep

@wraithgar
Copy link
Member

What we really need is a descendant operator to allow us to specify the edges out types. root > :dep(dev) would be everything in the root package's devDependencies for example

@wraithgar wraithgar changed the title [query] direct descendant > selector as logical AND operator [query] need a descendant operator that can specify type Jan 9, 2023
@saquibkhan saquibkhan assigned lukekarrys and unassigned wraithgar Jan 11, 2023
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

3 participants