Skip to content

fix: deduplicate GraphQL queries, sync version, fix CI badge, remove dead hook#21

Merged
ryanio merged 1 commit intomainfrom
devin/1772034527-cleanup-fixes
Feb 25, 2026
Merged

fix: deduplicate GraphQL queries, sync version, fix CI badge, remove dead hook#21
ryanio merged 1 commit intomainfrom
devin/1772034527-cleanup-fixes

Conversation

@ryanio
Copy link
Collaborator

@ryanio ryanio commented Feb 25, 2026

Summary

Four small cleanup fixes identified during a codebase audit:

  1. Deduplicate GraphQL queries — The same 4 search query strings were copy-pasted in both src/commands/search.ts and src/sdk.ts. Extracted into a new shared src/queries.ts module that both files now import from.
  2. Sync CLI versioncli.ts had a hardcoded .version("0.1.0") while package.json is at 0.1.5. Now reads process.env.npm_package_version (set automatically by npm at runtime) with a "0.0.0" fallback.
  3. Fix README CI badge — Badge pointed to npm-publish.yml; updated to point to ci.yml.
  4. Remove dead postAction hookprogram.hook("postAction", () => {}) was a no-op.

Review & Testing Checklist for Human

  • Verify process.env.npm_package_version works for all invocation methods. This env var is set by npm when running via npx opensea-cli or npm run, but will not be set if someone runs node dist/cli.js directly — they'd see version 0.0.0. Confirm this tradeoff is acceptable, or if we should read version from package.json via createRequire/fs instead.
  • Confirm the postAction hook removal is safe. It was an empty callback, but occasionally empty Commander.js hooks serve a subtle purpose (e.g., ensuring async command completion). Verify opensea --help and a real command still work correctly after removal.
  • Spot-check that the shared queries in src/queries.ts are identical to what sdk.ts previously had inline. The sdk.ts versions used compressed single-line field selections while commands/search.ts used expanded formatting — both are functionally equivalent in GraphQL, but the shared version uses the expanded format.

Suggested test plan: run npx opensea-cli --version and npx opensea-cli search collections mfers --limit 1 to verify version output and that search still works end-to-end.

Notes

  • All 113 existing tests pass; coverage is stable at 93.5%.
  • Lint, format, and type-check all pass locally.
  • Confidence: 🟢 HIGH on query dedup, badge fix, and hook removal. 🟡 MEDIUM on the version approach (works for npm-based invocation but not direct node invocation).

Link to Devin run: https://app.devin.ai/sessions/9848738941ed4994b46a79d50942a881
Requested by: @ryanio


Open with Devin

…dead hook

- Extract shared GraphQL queries into src/queries.ts used by both
  commands/search.ts and sdk.ts
- Read CLI version from npm_package_version instead of hardcoding 0.1.0
- Fix README CI badge to point to ci.yml instead of npm-publish.yml
- Remove unused empty postAction hook in cli.ts

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
Copy link
Contributor

Original prompt from Ryan
can you add a full unit and integration test suite to opensea-cli with full coverage
add a ci for lint and test as well
after you open the PR you should go back and forth with CI to ensure everything is passing


@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration bot marked this pull request as ready for review February 25, 2026 15:52
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@ryanio ryanio merged commit e8af3e5 into main Feb 25, 2026
4 checks passed
@ryanio ryanio deleted the devin/1772034527-cleanup-fixes branch February 25, 2026 15:56
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.

1 participant