Skip to content

Commit 3107ad1

Browse files
committed
fix: async stop and partial complete
1 parent 8209848 commit 3107ad1

File tree

7 files changed

+51
-26
lines changed

7 files changed

+51
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
88
"@oclif/core": "^4",
9-
"@oclif/multi-stage-output": "^0.4.0",
9+
"@oclif/multi-stage-output": "^0.5.0",
1010
"@salesforce/core": "^8.2.7",
1111
"@salesforce/kit": "^3.2.1",
1212
"@salesforce/sf-plugins-core": "^11.3.3",

src/commands/data-seeding/generate/index.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export default class DataSeedingGenerate extends SfCommand<DataSeedingGenerateRe
7979
const mso = getSeedGenerateMso({ jsonEnabled: this.jsonEnabled() });
8080
mso.updateData(baseData);
8181

82+
const completedStatus = ['Completed', 'Partially Completed', 'Failed'];
83+
8284
const options: PollingClient.Options = {
8385
poll: async (): Promise<StatusResult> => {
8486
const response = await pollSeedStatus(jobId);
@@ -90,7 +92,7 @@ export default class DataSeedingGenerate extends SfCommand<DataSeedingGenerateRe
9092
});
9193

9294
return {
93-
completed: response.status === 'Completed' || response.status === 'Failed',
95+
completed: completedStatus.includes(response.status),
9496
payload: response,
9597
};
9698
},
@@ -102,11 +104,16 @@ export default class DataSeedingGenerate extends SfCommand<DataSeedingGenerateRe
102104
const client = await PollingClient.create(options);
103105
const pollResult: PollSeedResponse = await client.subscribe();
104106

105-
if (pollResult.status === 'Failed') {
106-
mso.error();
107-
throw new SfError(`Data seeding job failed on step: ${pollResult.step}\nLog Text: ${pollResult.log_text}`);
108-
} else {
109-
mso.stop();
107+
switch (pollResult.status) {
108+
case 'Failed':
109+
mso.error();
110+
throw new SfError(`Data seeding job failed on step: ${pollResult.step}\nLog Text: ${pollResult.log_text}`);
111+
case 'Partially Completed':
112+
mso.stop('warning');
113+
this.log(`Process partially completed: ${pollResult.log_text}`);
114+
break;
115+
default:
116+
mso.stop('current');
110117
}
111118

112119
return buildResponse(pollResult);
@@ -138,7 +145,7 @@ export default class DataSeedingGenerate extends SfCommand<DataSeedingGenerateRe
138145
status: 'Initiated',
139146
});
140147

141-
mso.stop('current');
148+
mso.stop('async');
142149
this.log(reportMessage);
143150

144151
return buildResponse(response);

src/commands/data-seeding/generate/report.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export default class DataSeedingGenerateReport extends SfCommand<DataSeedingRepo
6464
case 'In Progress':
6565
mso.stop('current');
6666
break;
67+
case 'Partially Completed':
68+
mso.stop('warning');
69+
this.log(`Process partially completed: ${response.log_text}`);
70+
break;
6771
case 'Failed':
6872
mso.error();
6973
throw new SfError(`Failed on step: ${response.step}\nLog Text: ${response.log_text}`);

src/commands/data-seeding/migrate/index.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export default class DataSeedingMigrate extends SfCommand<DataSeedingMigrateResu
7979
const mso = getSeedMigrateMso({ jsonEnabled: this.jsonEnabled() });
8080
mso.updateData(baseData);
8181

82+
const completedStatus = ['Completed', 'Partially Completed', 'Failed'];
83+
8284
const options: PollingClient.Options = {
8385
poll: async (): Promise<StatusResult> => {
8486
const response = await pollSeedStatus(jobId);
@@ -90,7 +92,7 @@ export default class DataSeedingMigrate extends SfCommand<DataSeedingMigrateResu
9092
});
9193

9294
return {
93-
completed: response.status === 'Completed' || response.status === 'Failed',
95+
completed: completedStatus.includes(response.status),
9496
payload: response,
9597
};
9698
},
@@ -102,11 +104,16 @@ export default class DataSeedingMigrate extends SfCommand<DataSeedingMigrateResu
102104
const client = await PollingClient.create(options);
103105
const pollResult: PollSeedResponse = await client.subscribe();
104106

105-
if (pollResult.status === 'Failed') {
106-
mso.error();
107-
throw new SfError(`Data migration job failed on step: ${pollResult.step}\nLog Text: ${pollResult.log_text}`);
108-
} else {
109-
mso.stop();
107+
switch (pollResult.status) {
108+
case 'Failed':
109+
mso.error();
110+
throw new SfError(`Data migration job failed on step: ${pollResult.step}\nLog Text: ${pollResult.log_text}`);
111+
case 'Partially Completed':
112+
mso.stop('warning');
113+
this.log(`Process partially completed: ${pollResult.log_text}`);
114+
break;
115+
default:
116+
mso.stop('current');
110117
}
111118

112119
return buildResponse(pollResult);
@@ -138,7 +145,7 @@ export default class DataSeedingMigrate extends SfCommand<DataSeedingMigrateResu
138145
status: 'Initiated',
139146
});
140147

141-
mso.stop('current');
148+
mso.stop('async');
142149
this.log(reportMessage);
143150

144151
return buildResponse(response);

src/commands/data-seeding/migrate/report.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ export default class DataSeedingMigrateReport extends SfCommand<DataSeedingRepor
6161
case 'In Progress':
6262
mso.stop('current');
6363
break;
64+
case 'Partially Completed':
65+
mso.stop('warning');
66+
this.log(`Process partially completed: ${response.log_text}`);
67+
break;
6468
case 'Failed':
6569
mso.error();
6670
throw new SfError(`Failed on step: ${response.step}\nLog Text: ${response.log_text}`);

src/utils/mso.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const getSeedMso = (overrides: SeedMsoOverrides = {}): MultiStageOutput<SeedGene
8383
get: (data): MsoGet => data?.jobId,
8484
type: 'static-key-value',
8585
label: 'Job ID',
86+
neverCollapse: true,
8687
},
8788
{
8889
get: (data): MsoGet => data?.sourceOrg,
@@ -103,16 +104,18 @@ const getSeedMso = (overrides: SeedMsoOverrides = {}): MultiStageOutput<SeedGene
103104
case 'Completed':
104105
case 'Initiated':
105106
return StandardColors.success(status);
106-
case 'Failed':
107-
return StandardColors.error(status);
108107
case 'Client Timeout':
108+
case 'Partially Completed':
109109
return StandardColors.warning(status);
110+
case 'Failed':
111+
return StandardColors.error(status);
110112
default:
111113
return status;
112114
}
113115
},
114116
type: 'static-key-value',
115117
label: 'Status',
118+
neverCollapse: true,
116119
},
117120
{
118121
get: (data): MsoGet => data?.startTime,

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,13 +1682,13 @@
16821682
wordwrap "^1.0.0"
16831683
wrap-ansi "^7.0.0"
16841684

1685-
"@oclif/multi-stage-output@^0.4.0":
1686-
version "0.4.0"
1687-
resolved "https://registry.yarnpkg.com/@oclif/multi-stage-output/-/multi-stage-output-0.4.0.tgz#353f43579e42d087bee3c6595d61dd05cd261327"
1688-
integrity sha512-nPXFhbYGBlXevzbinLCSg7ZSr87N/L70aQsvzDJjRMJK/b/fXr86khegPX4hIlLXJZOKgTCtko3hTWDH7P6cPw==
1685+
"@oclif/multi-stage-output@^0.5.0":
1686+
version "0.5.0"
1687+
resolved "https://registry.yarnpkg.com/@oclif/multi-stage-output/-/multi-stage-output-0.5.0.tgz#92409f46c2825a794f63171f552b64b469b9fd81"
1688+
integrity sha512-XbeF7ASB7nHDlgyiGO9oxfkf/r5osSMu7C3RT/zl+RxANFEr7scCU2nAJ+9TCgMSGg9/EGgzZ1a1CmKpi/LLdQ==
16891689
dependencies:
16901690
"@oclif/core" "^4"
1691-
"@types/react" "^18.3.4"
1691+
"@types/react" "^18.3.5"
16921692
change-case "^5.4.4"
16931693
cli-spinners "^2"
16941694
figures "^6.1.0"
@@ -2580,10 +2580,10 @@
25802580
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.12.tgz#12bb1e2be27293c1406acb6af1c3f3a1481d98c6"
25812581
integrity sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==
25822582

2583-
"@types/react@^18.3.4":
2584-
version "18.3.4"
2585-
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.4.tgz#dfdd534a1d081307144c00e325c06e00312c93a3"
2586-
integrity sha512-J7W30FTdfCxDDjmfRM+/JqLHBIyl7xUIp9kwK637FGmY7+mkSFSe6L4jpZzhj5QMfLssSDP4/i75AKkrdC7/Jw==
2583+
"@types/react@^18.3.5":
2584+
version "18.3.5"
2585+
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.5.tgz#5f524c2ad2089c0ff372bbdabc77ca2c4dbadf8f"
2586+
integrity sha512-WeqMfGJLGuLCqHGYRGHxnKrXcTitc6L/nBUWfWPcTarG3t9PsquqUMuVeXZeca+mglY4Vo5GZjCi0A3Or2lnxA==
25872587
dependencies:
25882588
"@types/prop-types" "*"
25892589
csstype "^3.0.2"

0 commit comments

Comments
 (0)