cli icon indicating copy to clipboard operation
cli copied to clipboard

Add `--variable-file` flag for bulk operation mutations

Open ericlee878 opened this issue 1 month ago β€’ 4 comments

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

ericlee878 avatar Nov 19 '25 01:11 ericlee878

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

ericlee878 avatar Nov 19 '25 01:11 ericlee878

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟑 Statements
79.22% (+0.01% πŸ”Ό)
13660/17244
🟑 Branches
73.15% (+0.06% πŸ”Ό)
6662/9107
🟑 Functions
79.33% (-0.02% πŸ”»)
3520/4437
🟑 Lines
79.57% (+0.01% πŸ”Ό)
12902/16214
Show files with reduced coverage πŸ”»
St.:grey_question:
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 c6078b14238d4b892e6cf27c85bb2cbc440e2dbe

github-actions[bot] avatar Nov 19 '25 01:11 github-actions[bot]

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.

github-actions[bot] avatar Nov 19 '25 01:11 github-actions[bot]

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

github-actions[bot] avatar Nov 19 '25 21:11 github-actions[bot]