1

有没有办法确定 NPM 包的源存储库 URL?查看https://registry.npmjs.org API 它没有指向包的源?

我试图弄清楚如何从依赖包返回到它的源 - 可能以某种自动化方式。有人有什么见解可以分享吗?

例如反应的 npmjs.org 页面:

React 在 NPM 的包

清楚地显示“存储库”链接。但“注册表”不包含此信息。我想从 API/CouchDB 数据库中获取到https://github.com/facebook/react的 Github url。

更新:发现“包”API 确实提供了我正在寻找的数据。

curl https://replicate.npmjs.com/react | jq

回报:

...
"repository": {
    "type": "git",
    "url": "git+https://github.com/facebook/react.git",
    "directory": "packages/react"
  }
...

curl https://replicate.npmjs.com/_all_docs\?include_docs\=true -o npm.full.json不包括该信息。

4

1 回答 1

1

答案是提供此信息的 API 直接是包:

curl https://replicate.npmjs.com/react | jq
于 2020-04-22T18:28:57.153 回答