Skip to content

Add typed JSON output to app security clean - #8963

Open
jek wants to merge 2 commits into
mainfrom
app-security/support-json-schema-clean
Open

jek wants to merge 2 commits into
mainfrom
app-security/support-json-schema-clean

Conversation

@jek

@jek jek commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

The shopify app security commands have no --json output: they're listed as exceptions in the JSON output lint rule. Coding agents and scripts that drive the app security workflow have to read terminal boxes instead. This stack adds typed JSON output to each command, one PR per command, and then switches the agent workflow to it.

WHAT is this pull request doing?

Adds --json to app security clean. The result says whether anything was removed, and lists the removed results directories as absolute paths:

{"status": "success", "changed": true,
 "app": {"directory": "/path/to/app", "configurationPath": "/path/to/app/shopify.app.toml", "clientId": "1234"},
 "resultsDirectories": ["/path/to/app/.shopify/app-security/shopify.app"]}
  • With --all, only the app directory is known, so app holds only directory. Nothing to remove gives changed: false and an empty list.
  • A missing results directory fails with the code results-directory-not-found, which record and review share.
  • app-security-json-output.ts holds the definitions that the other app security commands reuse, starting with app.

The first commit moves the terminal presenter to security-clean/result.ts without changing behaviour.

How to manually test your changes?

Build once and run the local CLI directly, so nothing else reaches stdout:

pnpm nx build cli
alias shopify-dev="node $PWD/packages/cli/bin/dev.js"

In an app directory:

shopify-dev app security check --path <app> --no-input --skip-instructions
shopify-dev app security clean --path <app> --json                # removes the results directory
shopify-dev app security clean --path <app> --json; echo "exit $?" # error with code results-directory-not-found, exit 1
shopify-dev app security clean --path <app> --all --json          # changed: false, app has only directory

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

jek added 2 commits October 20, 2026 16:43
The clean result's JSON codec and presenter will live in
security-clean/, beside its schema, as for dev clean. The text output
doesn't change.
`--json` prints the removed results directories and the app they belong
to. With `--all`, only the app directory is known, so `app` holds only
`directory`. The shared app-security JSON module starts with the app
projection that the other app security commands will reuse.

`--all` now lists the removed directories sorted, so the order no longer
depends on the filesystem, in text and JSON alike.

A missing results directory aborts with the `results-directory-not-found`
code, so callers can tell it apart without parsing the message.
@jek
jek added this pull request to stack #8969 October 21, 2026 00:00
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Oct 21, 2026
@jek jek changed the title app security/support json schema clean Add typed JSON output to app security clean Oct 21, 2026
@jek
jek marked this pull request as ready for review October 21, 2026 13:50
@jek
jek requested review from a team as code owners October 21, 2026 13:50

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant