Skip to content

Add/enforce --json and output boundary for store commands#7190

Open
dmerand wants to merge 1 commit intodlm-store-restructurefrom
dlm-store-json-v2
Open

Add/enforce --json and output boundary for store commands#7190
dmerand wants to merge 1 commit intodlm-store-restructurefrom
dlm-store-json-v2

Conversation

@dmerand
Copy link
Copy Markdown
Contributor

@dmerand dmerand commented Apr 3, 2026

What

Add --json to shopify store auth and shopify store execute.

This makes the final command contract object-first: the structured result is canonical, and human-readable output is derived from that same result.

Why

shopify store * commands are intended to work well for agents and scripts as well as humans.

The lower PRs make the auth and execute domain boundaries clearer, but the top-of-stack command contract still needed a JSON path for final results. This PR adds that path without changing the default human-readable behavior.

How

  • add --json to shopify store auth
  • add --json to shopify store execute
  • make authenticateStoreWithApp(...) return a structured auth result and route final display through an auth presenter
  • keep browser/manual-auth guidance on stderr while writing JSON auth results to stdout
  • make executeStoreOperation(...) return the GraphQL result instead of owning final output
  • move execute output/file-writing back to the command boundary via writeOrOutputStoreExecuteResult(...)
  • remove outputFile from the prepared execute request so request parsing stays separate from output policy

High-level flow after this PR:

sequenceDiagram
    participant Command
    participant Service
    participant Result as Canonical result
    participant Renderer as Text/JSON renderer
    participant Stdout
    participant Stderr

    Command->>Service: run operation
    Service-->>Command: structured result
    Command->>Renderer: render(result, format)
    alt format = json
        Renderer->>Stdout: final structured result
    else format = text
        Renderer->>Stderr: human-readable summary
    end
Loading

Out of scope here:

  • shopify store auth info
  • shopify store auth logout

Those commands are still experimental and are intentionally left out of this PR.

Testing

Manual checks:

pnpm run shopify store auth --store donaldmerand.myshopify.com --scopes read_products --json
pnpm run shopify store execute --store donaldmerand.myshopify.com --query 'query { shop { name id } }' --json
pnpm run shopify store auth --help
pnpm run shopify store execute --help

Verify that:

  • --json is listed in help for both commands
  • store auth --json prints only the final auth result to stdout
  • browser/manual-auth guidance still goes to stderr
  • store execute --json prints only the GraphQL result to stdout
  • --output-file still writes the JSON result without a human success banner in JSON mode

Considered

  • Reuse the older dlm-store-json shape directly: rejected; this PR is rebuilt on top of the cleaned auth/execute seams.
  • Broaden this PR to include store auth info/logout: out of scope while those commands are still experimental.
  • Keep final output ownership inside execute service flow: rejected in favor of command/output-seam ownership.

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 force-pushed the dlm-store-json-v2 branch from 179bc33 to 834d827 Compare April 3, 2026 20:15
@dmerand dmerand changed the title Add/enforce --json for store commands Add/enforce --json and output boundary for store commands Apr 3, 2026
@dmerand dmerand marked this pull request as ready for review April 3, 2026 20:49
@dmerand dmerand requested review from a team as code owners April 3, 2026 20:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

@dmerand dmerand force-pushed the dlm-store-restructure branch from b8cace6 to 2259cc1 Compare April 3, 2026 20:51
@dmerand dmerand force-pushed the dlm-store-json-v2 branch from 834d827 to 3ea6614 Compare April 3, 2026 20:51
@dmerand dmerand requested a review from ryancbahan April 3, 2026 20:57
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