Skip to content

feat: --json for jh package info, dependency and dependents - #69

Merged
pankgeorg merged 4 commits into
mainfrom
feat/package-json
Oct 15, 2026
Merged

pankgeorg merged 4 commits into
mainfrom
feat/package-json

Conversation

@pankgeorg

@pankgeorg pankgeorg commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Adds --json to jh package info, jh package dependency and jh package dependents. Each prints only a JSON document on stdout, 2-space indented with a trailing newline, as jh package search --json already does; errors from these commands now go to stderr.

  • info: {"results": [...], "total": N}, the same document as package search --json, holding the exact matches (one per registry); no match gives {"results": [], "total": 0}.
  • dependency: {"name", "version", "registry", "dependencies": [...]}; --indirect adds the indirect dependencies, and each entry carries direct.
  • dependents: {"name", "version", "registry", "direct", "indirect", "total", "dependents": [...]}; the counts always cover every dependent, and dependents lists the indirect ones only with --indirect.

getPackageInfo now collects matches (REST, then the GraphQL fallback) and prints once, and writeJSON is shared by every package JSON document. Checked against juliahub.com: info JuMP --json, dependency JuMP --json [--indirect] (9 / 57 entries), dependents JuMP --json [--indirect] (335 direct, 94 indirect, 429 total; 335 / 429 listed), a missing package, and an error (empty stdout, exit 1).

#67 is on main and this branch is rebased onto it.

This PR also carries #70 (jh package info shows downloads, owner and the package's pkg.json details) and #72 (clearer text output for the jh package commands, --short for dependency and dependents), which were approved and merged into this branch; their descriptions cover those changes. The branch holds one commit per feature, and its tree is identical to the approved head of #72.

krynju
krynju previously approved these changes Oct 15, 2026

@krynju krynju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Note: GitHub shows a conflict only because #67 was squash-merged; git rebase origin/main drops the duplicated commit cleanly.

pankgeorg and others added 4 commits October 15, 2026 18:12
Each prints only a JSON document on stdout, 2-space indented with a trailing
newline, like `jh package search --json`:

- `info`: `{"results": [...], "total": N}`, the same document as
  `package search --json`, holding the exact matches (one per registry); no
  match gives an empty `results`.
- `dependency`: `{"name", "version", "registry", "dependencies": [...]}`;
  `--indirect` adds the indirect dependencies, each entry carries `direct`.
- `dependents`: `{"name", "version", "registry", "direct", "indirect",
  "total", "dependents": [...]}`; the counts always cover every dependent,
  and `dependents` lists the indirect ones only with `--indirect`.

`getPackageInfo` now collects the matches (REST, then GraphQL) and prints
once, and `writeJSON` is shared by every package JSON document. Errors from
these three commands go to stderr, so stdout holds only the document.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…json details

The REST listing already returns `owner`, `is_app`, `is_dyad` and
`downloads_timeseries`, but `RESTPackage` dropped them (it decoded a
`downloads.count` the API does not send). `restToInfo` now carries them, with
`downloads_30d` as the sum of the 30 daily counts, so `jh package search
--verbose`/`--json` show them too.

`jh package info` also fetches the stable version's pkg.json for each match
and prints its homepage, release date, dependency and dependent counts,
contributors and docs build type. In `--json` these are under `details`,
together with the daily download counts and the full contributor list. If
pkg.json cannot be fetched, a warning goes to stderr and the listing fields
are still printed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- `info` (and `search --verbose`) print a card per package: a header line
  `name  vX · registry · owner`, the description, then aligned fields with
  thousands separators, a 30-day download sparkline, a link to the package's
  JuliaHub page and an install hint.
- `search` prints an aligned table with STARS and DL/30 DAYS columns; the
  OWNER separator and VERSION column used to be wider than their headers.
  Long names and descriptions are cut at rune boundaries with "…".
- `dependency` and `dependents` print the same heading and
  direct/indirect/total counts, with standard libraries shown as `stdlib`.
  `dependency` lists each package once: `deps` can hold a package as both
  direct and indirect, and `splitDependencies` keeps one entry per UUID (direct
  wins), in `--json` too.

Bold and dim styling is used only when stdout is a terminal, `NO_COLOR` is
unset and `TERM` is not `dumb`. The helpers live in `style.go`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Prints a single line with the counts, e.g.

    JuMP  v1.32.1 · General: 9 direct · 40 indirect · 49 total dependencies

`--short` cannot be combined with `--json`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pankgeorg
pankgeorg requested a review from krynju October 15, 2026 15:14
pankgeorg added a commit that referenced this pull request Oct 15, 2026
Each prints only a JSON document on stdout, 2-space indented with a trailing
newline:

- `info`: `{"results": [...], "total": N}` holding the exact matches (one
  per registry); no match gives an empty `results`.
- `dependency`: `{"name", "version", "registry", "dependencies": [...]}`;
  `--indirect` adds the indirect dependencies, each entry carries `direct`.
- `dependents`: `{"name", "version", "registry", "direct", "indirect",
  "total", "dependents": [...]}`; the counts always cover every dependent,
  and `dependents` lists the indirect ones only with `--indirect`.

`getPackageInfo` now collects the matches (REST, then GraphQL) and prints
once. Errors from these three commands go to stderr, so stdout holds only the
document.

Backport of #69 (6186cca) to the 0.4 line, which has no
`jh package search --json`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pankgeorg
pankgeorg merged commit 2112fcd into main Oct 15, 2026
1 check passed
@pankgeorg
pankgeorg deleted the feat/package-json branch October 15, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants