Skip to content

PROTO: Add --json to store commands#7186

Draft
dmerand wants to merge 1 commit intodlm-store-auth-logoutfrom
dlm-store-json
Draft

PROTO: Add --json to store commands#7186
dmerand wants to merge 1 commit intodlm-store-auth-logoutfrom
dlm-store-json

Conversation

@dmerand
Copy link
Copy Markdown
Contributor

@dmerand dmerand commented Apr 3, 2026

What

Add explicit --json support across the shopify store * command surface in this stack:

  • shopify store auth
  • shopify store auth info
  • shopify store auth logout
  • shopify store execute

This also pushes the store-command internals toward an object-first shape, so services produce structured results and text rendering is derived from those results.

Why

These commands are intended to be agent-first surfaces, but their JSON behavior was inconsistent:

  • store auth was text-only
  • store auth logout was text-only
  • store execute printed JSON-ish results but did not expose an explicit --json contract
  • auth-related state was being rebuilt in multiple places

This change makes the machine-readable contract explicit while keeping the human output intact.

How

  • Add --json to store auth, store auth logout, and store execute
  • Keep store auth info on the same structured auth-state model as store auth
  • Extract shared auth-state building into packages/cli/src/cli/services/store/auth-state.ts
  • Refactor store auth so auth succeeds with a structured result and the presenter decides whether to render text or JSON
  • Keep store execute execution separate from final output, so the command writes/renders the returned result instead of mixing fetch and presentation in one service
  • Normalize store lookup inside getStoreAuthInfo(...) so the service seam is defensive even outside command parsing

Testing

Manual checks:

shopify store auth --store donaldmerand.myshopify.com --scopes read_products --json
shopify store auth info --store donaldmerand.myshopify.com --json
shopify store execute --store donaldmerand.myshopify.com --query "query { shop { name id } }" --json
shopify store execute --store donaldmerand.myshopify.com --query "query { shop { name id } }" --output-file /tmp/store-result.json --json
shopify store auth logout --store donaldmerand.myshopify.com --json

Things to verify:

  • store auth --json prints the final auth object to stdout without interleaving browser/progress text
  • store auth info --json and store auth logout --json return structured objects
  • store execute --json returns only the GraphQL result
  • store execute --output-file ... --json writes the result file without printing the human success banner
  • text mode for the same commands still renders the existing human-oriented output

Considered

  • Leaving store execute as implicitly JSON-like without an explicit flag
  • Keeping store execute execution and final output coupled in one service
  • Deferring the shared auth-state model and rebuilding auth output objects separately in each command

Post-release steps

None.

Measuring impact

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Copy Markdown
Contributor Author

dmerand commented Apr 3, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@dmerand dmerand mentioned this pull request Apr 3, 2026
5 tasks
@dmerand dmerand changed the title Add --json to store commands PROTO: Add --json to store commands Apr 3, 2026
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