Skip to content

Add typed JSON output to app function typegen - #8892

Merged
gonzaloriestra merged 5 commits into
gonzalo/function-schema-jsonfrom
gonzalo/function-typegen-json
Oct 16, 2026
Merged

gonzaloriestra merged 5 commits into
gonzalo/function-schema-jsonfrom
gonzalo/function-typegen-json

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Related to https://github.com/shop/issues-develop/issues/23666

WHY are these changes introduced?

app function typegen has no structured completion result for scripts and agents.

WHAT is this pull request doing?

Add --json and a discoverable FunctionTypegenResult schema. Return the completed Function's identity and route generator diagnostics through shared JSON events. Preserve the built-in and custom generator paths, text output, success banner, and existing failure handling. Output filenames are not inferred from arbitrary custom generator commands.

Normal output (excerpt):

GraphQL types generated successfully.

Matching JSON:

{
  "status": "success",
  "function": {
    "handle": "cart-transformer",
    "name": "Cart transformer",
    "directory": "/path/to/app/extensions/cart-transformer"
  }
}

How to manually test your changes?

shopify app function typegen --path /path/to/app/extensions/cart-transformer
shopify app function typegen --path /path/to/app/extensions/cart-transformer --json
shopify app function typegen --json-schema

Repeat with a Function that configures build.typegen_command.

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 — added the shared minor changeset for the new Function JSON flags

@gonzaloriestra
gonzaloriestra added this pull request to stack #8773 October 14, 2026 14:25
@gonzaloriestra

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Built from 07b4acfba9fd53d413915eae2d93ab8030422bc6. Workflow run.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261014142627

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@isaacroldan isaacroldan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Found two CI issues introduced here.


🤖 Generated by the review-pr skill

Comment thread packages/app/src/cli/commands/app/function/typegen.test.ts Outdated
Comment thread packages/app/src/cli/commands/app/function/typegen.ts
@gonzaloriestra

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Built from ee171bf435b7992013d567f0c6556d67acfcbe08. Workflow run.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261015150445

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/function-typegen-json branch from ee171bf to c95fae8 Compare October 15, 2026 15:36
@gonzaloriestra

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

Copy link
Copy Markdown
Contributor

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Built from c95fae8f5ff2a488cd4a604ec40618d1fc99eb2e. Workflow run.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261015154027

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@gonzaloriestra
gonzaloriestra marked this pull request as ready for review October 15, 2026 15:52
@gonzaloriestra
gonzaloriestra requested review from a team as code owners October 15, 2026 15:52
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/function-typegen-json branch from c95fae8 to 92f3991 Compare October 15, 2026 16:06
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/function-typegen-json branch from 92f3991 to a1f05bf Compare October 16, 2026 09:12
@github-actions

Copy link
Copy Markdown
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/base-command.d.ts
@@ -1,5 +1,4 @@
 import { type JsonOutputSchema } from './json-output-schema.js';
-import { JsonMap } from '../../private/common/json.js';
 import { Command } from '@oclif/core';
 import { OutputFlags, Input, ParserOutput, FlagInput, OutputArgs } from '@oclif/core/parser';
 export type ArgOutput = OutputArgs<any>;
@@ -37,8 +36,6 @@ declare abstract class BaseCommand extends Command {
         argv: string[];
     }>;
     protected environmentsFilename(): string | undefined;
-    protected parseEnvironmentFlags<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(environment: JsonMap, options: Input<TFlags, TGlobalFlags, TArgs>, explicitFlags: FlagOutput): Promise<FlagOutput>;
-    protected validateNonTTYFlags(flags: FlagOutput): void;
     protected failMissingNonTTYFlags(flags: FlagOutput, requiredFlags: string[]): void;
     private failMissingNonTTYFlagRequirements;
     private applicableNonTTYFlagRequirements;
packages/cli-kit/dist/public/node/system.d.ts
@@ -8,6 +8,8 @@ export interface ExecOptions {
     stderr?: Writable | 'inherit';
     stdio?: 'inherit';
     input?: string;
+    /** Whether to remove the final newline from captured stdout/stderr (default: true). */
+    stripFinalNewline?: boolean;
     signal?: AbortSignal;
     externalErrorHandler?: (error: unknown) => Promise<void>;
     background?: boolean;
@@ -42,6 +44,7 @@ export interface CaptureOutputResult {
 /**
  * Runs a command asynchronously and returns stdout, stderr, and exit code.
  * Unlike captureOutput, this function does NOT throw on non-zero exit codes.
+ * Startup failures and signal termination still throw an ExternalError.
  *
  * @param command - Command to be executed.
  * @param args - Arguments to pass to the command.
@@ -61,6 +64,7 @@ export declare function captureOutputWithExitCode(command: string, args: string[
  * Runs a command string asynchronously and returns stdout, stderr, and exit code.
  * Parses the command string into command and arguments (handles quoted strings).
  * Unlike captureOutput, this function does NOT throw on non-zero exit codes.
+ * Startup failures and signal termination still throw an ExternalError.
  *
  * @param command - Full command string to be executed (e.g., 'ls -la "my folder"').
  * @param options - Optional settings for how to run the command.

@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/function-typegen-json branch from a1f05bf to d863110 Compare October 16, 2026 09:27
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/function-typegen-json branch from d863110 to 692dd6a Compare October 16, 2026 09:36
Comment thread packages/app/src/cli/commands/app/function/typegen.ts
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/function-typegen-json branch from 692dd6a to 8857a40 Compare October 16, 2026 10:17
@gonzaloriestra
gonzaloriestra added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Oct 16, 2026
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/function-typegen-json branch from 8857a40 to 7d1a5bc Compare October 16, 2026 11:33
@gonzaloriestra
gonzaloriestra added this pull request to the merge queue Oct 16, 2026
Merged via the queue into main with commit 5704092 Oct 16, 2026
29 of 31 checks passed
@gonzaloriestra
gonzaloriestra deleted the gonzalo/function-typegen-json branch October 16, 2026 12:12
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.

2 participants