Search code examples
npmartifactorynpxnpm-registry

List all existing npm packages in remote registry


There's our internal deployed registry (JFrog Artifactory). And there we have an NPM registry with repo npm-virtual, which can be accessed for requests by a link https://artifactory.xyz.com/artifactory/api/npm/npm-virtual

I wonder, is there an npm/npx/... bash command, that can help me get the list of every package, that we contain in our registry?

npx npm-registry-fetch ls --registry=https://artifactory.xyz.com/artifactory/api/npm/npm-virtual

resulted with: npm ERR! could not determine executable to run

Every other command I've found requires a reference to exact package that I'm looking for.


Solution

  • One way to get all packages is to use the JFrog CLI search command:

    1. Configure your Artifactory server:
    jf c add
    
    1. Run the search command:
    jf rt s "npm-virtual/*.tgz"
    

    Results:

    [
      {
        "path": "npm-remote-cache/mri/-/mri-1.2.0.tgz",
        "type": "file",
        "size": 4448,
        "created": "2022-12-06T07:30:45.533Z",
        "modified": "2021-09-12T22:35:55.000Z",
        "sha1": "6721480fec2a11a4889861115a48b6cbe7cc8f0b",
        "sha256": "9e383990963c167baa471cc928a02eb1768ee2ffabf8117082a09b5213f9a575",
        "md5": "3447f63dcd06670e37015dddee114918",
        "props": {
          "artifactory.internal.etag": [
            "\"3447f63dcd06670e37015dddee114918\""
          ],
          "artifactory.licenses": [
            "MIT"
          ],
          "npm.description": [
            "quickly scan for cli flags and arguments"
          ],
          "npm.keywords": [
            "[\"argv\",\"arguments\",\"cli\",\"minimist\",\"options\",\"optimist\",\"parser\",\"args\"]"
          ],
          "npm.name": [
            "mri"
          ],
          "npm.version": [
            "1.2.0"
          ]
        }
      },
      {
        "path": "npm-remote-cache/dequal/-/dequal-2.0.3.tgz",
        "type": "file",
        "size": 4286,
        "created": "2022-12-06T07:30:45.560Z",
        "modified": "2022-07-11T23:29:06.000Z",
        "sha1": "2644214f1997d39ed0ee0ece72335490a7ac67be",
        "sha256": "941d90d6629878167d10d2a05d8c6df8f8fa13acc826616abb49db63ac6a5c35",
        "md5": "65cb9dc71fa9ec2c942ad60fe62c3b37",
        "props": {
          "artifactory.internal.etag": [
            "\"65cb9dc71fa9ec2c942ad60fe62c3b37\""
          ],
          "artifactory.licenses": [
            "MIT"
          ],
          "npm.description": [
            "a tiny (304b to 489b) utility for check for deep equality"
          ],
          "npm.keywords": [
            "[\"deep\",\"deep-equal\",\"equality\"]"
          ],
          "npm.name": [
            "dequal"
          ],
          "npm.version": [
            "2.0.3"
          ]
        }
      }
    ]
    

    Combining with jq:

    jf rt s "npm-virtual/*.tgz" | jq '.[] | .path'
    

    Results:

    "npm-remote-cache/mri/-/mri-1.2.0.tgz"
    "npm-remote-cache/dequal/-/dequal-2.0.3.tgz"
    "npm-remote-cache/vfile-message/-/vfile-message-3.1.3.tgz"
    "npm-remote-cache/unist-util-is/-/unist-util-is-5.1.1.tgz"
    "npm-remote-cache/trough/-/trough-2.1.0.tgz"
    "npm-remote-cache/unist-util-generated/-/unist-util-generated-2.0.0.tgz"
    "npm-remote-cache/micromark-factory-label/-/micromark-factory-label-1.0.2.tgz"
    "npm-remote-cache/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-1.1.0.tgz"
    "npm-remote-cache/unist-util-stringify-position/-/unist-util-stringify-position-3.0.2.tgz"
    "npm-remote-cache/micromark-util-encode/-/micromark-util-encode-1.0.1.tgz"
    "npm-remote-cache/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz"
    

    Read more about it here:

    1. npm Packages with JFrog CLI
    2. Building Npm Packages Using the Npm Client
    3. Install JFrog CLI