Skip to content

codeintel: Automatically fetch and index LSIF-referenced NPM dependencies

Administrator requested to merge vg-npm-database-support into main

Created by: varungandhi-src

Builds on top of https://github.com/sourcegraph/sourcegraph/pull/28057 and https://github.com/sourcegraph/sourcegraph/pull/22984/ .

TODOs:

  • Add automated tests.
  • Figure out where to put the scheme constants. Earlier, I ran into an import cycle error when I did it carelessly. This has some explicit TODOs in the code.

Manual testing steps:

  1. Start with sg start enterprise-codeintel.
  2. Set npmPackages to enabled under experimental features under site-admin.
  3. Refresh and add NPM Dependencies as a code host.
  4. Add "[email protected]" under "dependencies" in the code host settings.
  5. Turn on auto-indexing and set up a policy. Make sure that repos with URLs matching npm/* will be covered.
  6.  npm pack [email protected]
     tar -xzvf got-12.0.0.tgz
     cd package
     git init && git add . && git commit -m "Temp."
     echo '{"compilerOptions":{"allowJs":true}}' > tsconfig.json
     npm install --ignore-scripts
     lsif-tsc -p .
     # Assuming you've got SRC_ACCESS_TOKEN and SRC_ENDPOINT set up in the environment
     src lsif upload -repo=npm/got -root=. -commit=bb23d1f0cb5d634d1da32804860810f8f2d5c176
  7. got and its dependencies should be available for search shortly (e.g. try searching for interface).

Merge request reports

Loading