Skip to content

Conversation

@ericlee878
Copy link
Contributor

@ericlee878 ericlee878 commented Nov 19, 2025

Summary

Adds a new --variable-file flag to shopify app execute that allows users to provide mutation variables from a JSONL file instead of passing them inline via --variables. This makes it easier to execute bulk operations with many variables.

Implementation Details

  • New function: parseVariablesToJsonl()
    • Validates mutual exclusivity of --variables and --variable-file
    • Reads and validates file existence
    • Returns variables in JSONL format
  • Restructured data flow to use JSONL strings throughout:
    • File content is passed through as JSONL
    • Reduces unnecessary conversions (no split/rejoin for files)
  • Simplified stageFile():
    • Now accepts variablesJsonl string parameter
    • Converts directly to Buffer for upload

Testing

Create a file called variables.jsonl. This should be in the file:

{"input":{"id":"gid://shopify/Product/123","tags":["test"]}}
{"input":{"id":"gid://shopify/Product/456","tags":["test2"]}}

Run this command:

pnpm shopify app execute \
  --path <PATH_TO_APP> \
  -q 'mutation productUpdate($input: ProductInput!) { ... }' \
  --variable-file ./variables.jsonl

Copy link
Contributor Author

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.

@ericlee878 ericlee878 changed the title implement-variable-file-flag Add --variable-file flag for bulk operation mutations Nov 19, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 19, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
79.25% (+0.01% 🔼)
13652/17226
🟡 Branches
73.17% (+0.05% 🔼)
6667/9112
🟡 Functions
79.37% (-0.02% 🔻)
3517/4431
🟡 Lines
79.6% (+0.01% 🔼)
12895/16199
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / stage-file.ts
72.73% (-1.56% 🔻)
62.5% (+9.17% 🔼)
83.33% (-2.38% 🔻)
71.88% (-1.65% 🔻)

Test suite run success

3375 tests passing in 1380 suites.

Report generated by 🧪jest coverage report action from 2c2b13c

@ericlee878 ericlee878 marked this pull request as ready for review November 19, 2025 01:32
@ericlee878 ericlee878 requested a review from a team as a code owner November 19, 2025 01:32
@github-actions
Copy link
Contributor

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.

@ericlee878 ericlee878 force-pushed the 11-18-implement-variable-file-flag branch from 33ff64e to 884c9f0 Compare November 19, 2025 01:46
@ericlee878 ericlee878 requested a review from a team as a code owner November 19, 2025 01:46
@ericlee878 ericlee878 force-pushed the 11-18-implement-variable-file-flag branch from 884c9f0 to 61d6550 Compare November 19, 2025 01:49
@ericlee878 ericlee878 force-pushed the 11-18-implement-variable-file-flag branch 2 times, most recently from 04238ad to f9696ab Compare November 19, 2025 21:19
@ericlee878 ericlee878 force-pushed the 11-17-malformed-graphql-operation-validation branch from ac1fd53 to 5c20695 Compare November 19, 2025 21:19
@ericlee878 ericlee878 force-pushed the 11-18-implement-variable-file-flag branch from f9696ab to 2c2b13c Compare November 19, 2025 21:23
@ericlee878 ericlee878 force-pushed the 11-17-malformed-graphql-operation-validation branch from 5c20695 to 3f00902 Compare November 19, 2025 21:23
@github-actions
Copy link
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/ui.d.ts
@@ -1,5 +1,4 @@
 import { FatalError as Fatal } from './error.js';
-import { TokenizedString } from './output.js';
 import { ConcurrentOutputProps } from '../../private/node/ui/components/ConcurrentOutput.js';
 import { handleCtrlC, render } from '../../private/node/ui.js';
 import { AlertOptions } from '../../private/node/ui/alert.js';
@@ -332,23 +331,21 @@ interface RenderTasksOptions {
  * Installing dependencies ...
  */
 export declare function renderTasks<TContext>(tasks: Task<TContext>[], { renderOptions, noProgressBar }?: RenderTasksOptions): Promise<TContext>;
-export interface RenderSingleTaskOptions<T> {
-    title: TokenizedString;
-    task: (updateStatus: (status: TokenizedString) => void) => Promise<T>;
-    renderOptions?: RenderOptions;
-}
 /**
- * Awaits a single task and displays a loading bar while it's in progress. The task's result is returned.
+ * Awaits a single promise and displays a loading bar while it's in progress. The promise's result is returned.
  * @param options - Configuration object
- * @param options.title - The initial title to display with the loading bar
- * @param options.task - The async task to execute. Receives an updateStatus callback to change the displayed title.
- * @param options.renderOptions - Optional render configuration
- * @returns The result of the task
+ * @param options.title - The title to display with the loading bar
+ * @param options.taskPromise - The promise to track
+ * @param renderOptions - Optional render configuration
+ * @returns The result of the promise
  * @example
  * ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  * Loading app ...
  */
-export declare function renderSingleTask<T>({ title, task, renderOptions }: RenderSingleTaskOptions<T>): Promise<T>;
+export declare function renderSingleTask<T>({ title, taskPromise }: {
+    title: string;
+    taskPromise: Promise<T> | (() => Promise<T>);
+}, { renderOptions }?: RenderTasksOptions): Promise<T>;
 export interface RenderTextPromptOptions extends Omit<TextPromptProps, 'onSubmit'> {
     renderOptions?: RenderOptions;
 }
packages/cli-kit/dist/private/node/ui/components/SingleTask.d.ts
@@ -1,9 +1,8 @@
-import { TokenizedString } from '../../../../public/node/output.js';
-interface SingleTaskProps<T> {
-    title: TokenizedString;
-    task: (updateStatus: (status: TokenizedString) => void) => Promise<T>;
-    onComplete?: (result: T) => void;
+import React from 'react';
+interface SingleTaskProps {
+    title: string;
+    taskPromise: Promise<unknown>;
     noColor?: boolean;
 }
-declare const SingleTask: <T>({ task, title, onComplete, noColor }: SingleTaskProps<T>) => JSX.Element | null;
+declare const SingleTask: ({ taskPromise, title, noColor }: React.PropsWithChildren<SingleTaskProps>) => JSX.Element | null;
 export { SingleTask };
\ No newline at end of file

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