Add `--variable-file` flag for bulk operation mutations
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
--variablesand--variable-file - Reads and validates file existence
- Returns variables in JSONL format
- Validates mutual exclusivity of
- 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
- #6643
: 2 dependent PRs (#6663
, #6667
) - #6636
π (View in Graphite) - #6632

- #6622

- #6596

- #6588
: 1 other dependent PR (#6595
) main
This stack of pull requests is managed by Graphite. Learn more about stacking.
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
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.
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
mainyou might see odd diffs, rebasemaininto 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