Conversation
Add `uniqueNames()` to `fetch-list.js` to deduplicate package names
from JSON and text inputs, handling both plain strings and `{name}`
objects. Wire up the existing `--no-cache` CLI flag to actually pass
`{ cache: false }` through to the packument client.
Refactor `importCommand` in `index.js` to gracefully handle missing
subcommands by attempting to load the command's `index.js` module
before falling back to a usage error.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
uniqueNames()helper tocli/cli/src/cmd/packument/fetch-list.jsthat deduplicates package names parsed from JSON and text input files, handling both plain string entries and{name, ...}objects. The existing--no-cacheCLI flag is wired through to the packument client by constructingrequestOptionsfromcli.values.cache.importCommandincli/cli/src/index.jsis refactored to gracefully handle invocations without a subcommand — it first attempts to load a command-levelindex.jsmodule before falling back to an informative usage error.Why
Input deduplication
loadPackageNamespreviously returned raw items verbatim, so duplicate entries in an input file caused redundant fetches. JSON inputs could also contain{name: "..."}objects instead of bare strings, which would silently pass through as non-string values.uniqueNames()normalizes both shapes, warns on unrecognized entries, and deduplicates via aSet.--no-cachepassthroughThe
--no-cacheflag was accepted by the argument parser but never forwarded toclient.request(). The newrequestOptionsobject conditionally sets{ cache: false }when the flag is present, so cache-busting actually takes effect.Subcommand fallback
importCommandpreviously required both a command and subcommand, throwing an opaque import error when only a top-level command was given. The refactored version tries./cmd/${cmd}/index.jsfirst and, if no index module exists, prints a clear "no subcommand provided" message with CLI usage before exiting.Risk Assessment
Low risk: All changes are additive. The dedup helper is a pure function. The
--no-cachewiring only activates when the flag is explicitly passed. TheimportCommandrefactor preserves the existing two-argument path unchanged and only adds a new fallback branch.