Skip to content

Instantly share code, notes, and snippets.

@nateous
Last active Sep 15, 2021
Embed
What would you like to do?
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