Skip to content

Commit c324f49

Browse files
when --watch is passed to execute, display live progress
1 parent 1e25fe3 commit c324f49

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

packages/app/src/cli/commands/app/execute.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import AppLinkedCommand, {AppLinkedCommandOutput} from '../../utilities/app-link
33
import {linkedAppContext} from '../../services/app-context.js'
44
import {storeContext} from '../../services/store-context.js'
55
import {runBulkOperationQuery} from '../../services/bulk-operation-run-query.js'
6+
import {watchBulkOperation} from '../../services/watch-bulk-operation.js'
67
import {globalFlags} from '@shopify/cli-kit/node/cli'
78
import {renderSuccess, renderInfo, renderWarning} from '@shopify/cli-kit/node/ui'
89
import {outputContent, outputToken} from '@shopify/cli-kit/node/output'
@@ -75,10 +76,24 @@ export default class Execute extends AppLinkedCommand {
7576

7677
renderInfo({customSections: infoSections})
7778

78-
renderSuccess({
79-
headline: 'Bulk operation started successfully!',
80-
body: 'Congrats!',
81-
})
79+
if (flags.watch) {
80+
const finalOperation = await watchBulkOperation({
81+
id: result.id,
82+
storeFqdn: store.shopDomain,
83+
})
84+
85+
if (finalOperation) {
86+
renderSuccess({
87+
headline: `Bulk operation ${finalOperation.status.toLowerCase()}!`,
88+
body: `${finalOperation.objectCount} objects processed`,
89+
})
90+
}
91+
} else {
92+
renderSuccess({
93+
headline: 'Bulk operation started successfully!',
94+
body: 'Congrats!',
95+
})
96+
}
8297
}
8398

8499
return {app: appContextResult.app}

packages/cli/oclif.manifest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,13 @@
892892
"hidden": false,
893893
"name": "verbose",
894894
"type": "boolean"
895+
},
896+
"watch": {
897+
"allowNo": false,
898+
"description": "Wait for bulk operation results before exiting.",
899+
"env": "SHOPIFY_FLAG_WATCH",
900+
"name": "watch",
901+
"type": "boolean"
895902
}
896903
},
897904
"hasDynamicHelp": false,

0 commit comments

Comments
 (0)