Skip to content

Instantly share code, notes, and snippets.

@nateous
Last active September 15, 2021 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nateous/5ea9d110a103f0682cb5bf424db3b387 to your computer and use it in GitHub Desktop.
Save nateous/5ea9d110a103f0682cb5bf424db3b387 to your computer and use it in GitHub Desktop.
Dependencies gathering

git pull all repos locally to parent dir

NUGET

From the parent dir run the following bash command

$ grep -r 'PackageReference Include' . >> nuget.txt

Using VS Code open nuget.txt and run the following regex to find and replace

find: \./([\w\.-]+)(?:/[\w\.-]+)*/([\w\.-]+)\.csproj:\s+<PackageReference Include="([^"]+)"(?: Version="([^"]+)")? ?/?>
replace: "$1","$2","$3","$4"

The result will be a csv file with REPO, CSPROJ, DEP_NAME, VERSION (add the headers)

NPM

From the parent dir run the following bash command

$ find . -name 'package-lock.json' | xargs cat >> all-package-lock.txt

Using VS Code open all-package-lock.txt and use the following regex to find and replace

Step 1
find: \s+"([^"]+)": \{\n\s+"version": "([^"]+)",
replace: \nDEPNODE "$1","$2"
Step 2
find: ^(?!DEPNODE).*\n
** note - replace with empty to remove lines that do not start with DEPNODE
Step 3
find: DEPNODE 
** note - space at the end of the pattern, and replace with empty to remove DEPNODE prefix

The result will be a csv file with npm_dep, version

Step 4 (optional, add the headers after this step)
$ sort input.csv | uniq -u > sorted-and-unique.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment