This is unmaintained library being open sourced for others to learn and fork from.
Patches will not be accepted. Issues are not likely to be responded to.
Add this line to your application's Gemfile:
gem 'library_version_analysis'And then execute:
$ bundle install
Or install it yourself as:
$ gem install library_version_analysis
analyze <repository> <source> [context]| Argument | Description |
|---|---|
repository |
The repository name (e.g., jobber) |
source |
The package manager: gemfile, npm, or pnpm |
context |
(Optional, pnpm only) A specific pnpm workspace to analyze |
# Analyze all gems
analyze my-repo gemfile
# Analyze all npm packages
analyze my-repo npm
# Analyze all pnpm workspaces
analyze my-repo pnpm
# Analyze a specific pnpm workspace
analyze my-repo pnpm packages/uiWhen using the pnpm source, the tool analyzes all workspaces by default. The optional context argument filters analysis to a single workspace by name. If the provided workspace name doesn't match any discovered workspace, the tool prints the available workspaces and exits.
This parameter is ignored for gemfile and npm sources.
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To use in development version of this code to analyze Jobber, replace the gem definition with jgem :enablers, "library_version_analysis", path: "/Users/johnz/workspace/library_version_analysis"
TODO when I next update, but...
Also remember to update (maybe, we don't know why yet) the bundle_cache_key in circle-ci as per this PR: https://github.com/GetJobber/Jobber/pull/40468/files
Used to read dependabot alerts
To create the github token:
- Under you profile, go to settings
- Now on the right side, click on Developer settings (near the bottom)
- Click on Personal access tokens -> Tokens (classic)
- Create a new classic token, selecting the (repo (all), read:package and read:project) scopes
The key used by LibraryTracking. See that project for the correct value.
deprecated
deprecated
deprecated
Update the gemfile to read: jgem :enablers, "library_version_analysis", path: "/Users/johnz/source/library_version_analysis"
then: bundle update --conservative library_version_analysis ln -s ../library_version_analysis . source library_version_anaysis/version.sh library_version_analysis/run.sh
For pnpm workspace repositories (monorepos), the CI pipeline must generate per-workspace libyear files before running the analysis. Each workspace gets its own libyear file with a hyphen-based naming convention.
| Workspace Path | Libyear Filename |
|---|---|
| Root (.) | libyear_root.txt |
| apps/client | libyear_apps-client.txt |
| apps/server | libyear_apps-server.txt |
| packages/ui | libyear_packages-ui.txt |
| Non-workspace repo | libyear_report.txt |
- name: Generate libyear reports
run: |
# Root workspace
pnpx libyear --package-manager pnpm --json > libyear_root.txt
# Each workspace (skip root at index 0)
for workspace in $(pnpm list -r --depth=-1 --json | jq -r '.[1:] | .[].path'); do
relative_path="${workspace#$(pwd)/}"
filename="libyear_${relative_path//\//-}.txt"
pnpx libyear --package-manager pnpm --json --cwd "$workspace" > "$filename" || true
done
- name: Run library analysis
run: ./exe/analyze $REPO_NAME pnpmFor non-workspace pnpm repositories (single package.json), continue using the existing single file approach:
pnpx libyear --package-manager pnpm --all --json > libyear_report.txtThis gem uploads per-workspace data to the library_tracking Rails app via POST /api/libraries/upload.
For each pnpm workspace, the gem sends a separate upload with:
{
"source": "<workspace_name>",
"repository": "<repository>",
"libraries": [...],
"new_versions": [...],
"vulnerabilities": [...],
"dependencies": [...]
}| Field | Value | Example |
|---|---|---|
repository |
The first CLI argument, passed through | "jobber-frontend" |
source |
The workspace name (root workspace becomes "root", nested workspaces use their relative path) |
"root", "packages/ui" |
For non-workspace pnpm repos, source is "pnpm". For other package managers, source matches the CLI argument ("gemfile", "npm").
The library_tracking database uniquely identifies a library by the composite index (name, source, repository_id). This means the same library (e.g., react) can exist independently in multiple workspaces within the same repository, each tracked with its own version history, vulnerabilities, and dependency graph.
Note: The DB diagram is outdated and does not show the
sourcecolumn on thelibrariestable. Refer todb/schema.rbin the library_tracking repo for the current schema.
Not supported
The gem is available as open source under the terms of the MIT License.