-
-
Save micalevisk/5276391d4e7b5c4b0c12fc98d5610245 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
## (c) 2022 Micael Levi L. C. | |
## This script requires: | |
## - npm (https://nodejs.org) | |
## - jq (https://stedolan.github.io/jq) | |
file="${1:-./package.json}" | |
[ -r "$file" ] || { echo "The file $file is not readable" ; exit 1 ; } | |
readarray -t pkgs < <(jq --raw-output '.dependencies | keys | .[]' "$file") | |
readarray -t modified_vals < <(printf 'npm view "%s" time.modified\n' ${pkgs[@]} | bash) | |
paste <(printf "%s\n" "${modified_vals[@]}") <(printf "%s\n" "${pkgs[@]}") | sort |
Hey Micael, thanks for this script, it works perfectly!
I was trying to figure out though what time.modified
even means.
Looking at e.g. https://github.com/shelljs/shx/commits/main I see that the last commit was on Aug 10 as of writing this. Running npm view shx --json
shows me time.modified
as 2022-06-26T19:13:27.666Z
So if it is not the latest commit on the main branch then what is it?
I would also argue that latest commit is a better indicator, since that seems to be newer than the time.modified
, at least in this case.
@mcmxcdev thanks! good question
here you can see how NPM computes that value: https://github.com/npm/cli/blob/34db56263c0d25caf5fff46e97f391e9ff094243/lib/commands/view.js#L350-L351
tbh I didn't fully understand it lol Keep in mind that a NPM package doesn't need to have a Git repo, so I believe that they don't try to look up for the last commit made
now you can see which packages seems to be unmaintained.