Skip to content

Commit 594e201

Browse files
wire up new watch UI to execute command
1 parent 80b2db8 commit 594e201

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default class Execute extends AppLinkedCommand {
3838
app: appContextResult.app,
3939
storeFqdn: store.shopDomain,
4040
query: flags.query,
41+
watch: flags.watch,
4142
})
4243

4344
return {app: appContextResult.app}

packages/app/src/cli/services/bulk-operations/execute-bulk-operation.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {runBulkOperationQuery} from './run-query.js'
2+
import {watchBulkOperation} from './watch-bulk-operation.js'
23
import {AppLinkedInterface} from '../../models/app/app.js'
34
import {renderSuccess, renderInfo, renderWarning} from '@shopify/cli-kit/node/ui'
45
import {outputContent, outputToken} from '@shopify/cli-kit/node/output'
@@ -7,10 +8,11 @@ interface ExecuteBulkOperationInput {
78
app: AppLinkedInterface
89
storeFqdn: string
910
query: string
11+
watch?: boolean
1012
}
1113

1214
export async function executeBulkOperation(input: ExecuteBulkOperationInput): Promise<void> {
13-
const {app, storeFqdn, query} = input
15+
const {app, storeFqdn, query, watch = false} = input
1416

1517
renderInfo({
1618
headline: 'Starting bulk operation.',
@@ -57,9 +59,23 @@ export async function executeBulkOperation(input: ExecuteBulkOperationInput): Pr
5759

5860
renderInfo({customSections: infoSections})
5961

60-
renderSuccess({
61-
headline: 'Bulk operation started successfully!',
62-
body: 'Congrats!',
63-
})
62+
if (watch) {
63+
const finalOperation = await watchBulkOperation({
64+
id: result.id,
65+
storeFqdn,
66+
})
67+
68+
if (finalOperation) {
69+
renderSuccess({
70+
headline: `Bulk operation ${finalOperation.status.toLowerCase()}!`,
71+
body: `${finalOperation.objectCount} objects processed`,
72+
})
73+
}
74+
} else {
75+
renderSuccess({
76+
headline: 'Bulk operation started successfully!',
77+
body: 'Congrats!',
78+
})
79+
}
6480
}
6581
}

0 commit comments

Comments
 (0)