Skip to content

Commit e1ca7d9

Browse files
Merge pull request #225 from salesforcecli/wr/addMSO
Wr/add mso @W-19803938@
2 parents c7605b7 + 5bf7561 commit e1ca7d9

File tree

3 files changed

+1192
-1404
lines changed

3 files changed

+1192
-1404
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"@inquirer/prompts": "^7.8.6",
1010
"@oclif/core": "^4",
1111
"@oclif/multi-stage-output": "^0.8.23",
12-
"@salesforce/agents": "^0.17.10",
12+
"@salesforce/agents": "^0.17.11",
1313
"@salesforce/core": "^8.23.1",
1414
"@salesforce/kit": "^3.2.3",
1515
"@salesforce/sf-plugins-core": "^12.2.4",

src/commands/agent/validate/authoring-bundle.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import { readFileSync } from 'node:fs';
1717
import { join } from 'node:path';
1818
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
1919
import { Messages, SfError } from '@salesforce/core';
20+
import { MultiStageOutput } from '@oclif/multi-stage-output';
2021
import { Agent, findAuthoringBundle } from '@salesforce/agents';
22+
import { Duration, sleep } from '@salesforce/kit';
23+
import { colorize } from '@oclif/core/ux';
2124
import { FlaggablePrompt, promptForFlag } from '../../../flags.js';
2225

2326
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
@@ -73,25 +76,57 @@ export default class AgentValidateAuthoringBundle extends SfCommand<AgentValidat
7376
messages.getMessage('error.agentNotFoundAction'),
7477
]);
7578
}
79+
const mso = new MultiStageOutput<{ status: string; errors: string }>({
80+
jsonEnabled: this.jsonEnabled(),
81+
title: `Validating ${apiName} Authoring Bundle`,
82+
showTitle: true,
83+
stages: ['Validating Authoring Bundle'],
84+
stageSpecificBlock: [
85+
{
86+
stage: 'Validating Authoring Bundle',
87+
label: 'Status',
88+
type: 'dynamic-key-value',
89+
get: (data): string => data?.status ?? 'IN PROGRESS',
90+
},
91+
{
92+
stage: 'Validating Authoring Bundle',
93+
label: 'Errors',
94+
type: 'dynamic-key-value',
95+
get: (data): string => data?.errors ?? '0',
96+
},
97+
],
98+
});
7699

77100
try {
101+
mso.skipTo('Validating Authoring Bundle');
78102
const targetOrg = flags['target-org'];
79103
const conn = targetOrg.getConnection(flags['api-version']);
80104
// Call Agent.compileAfScript() API
105+
await sleep(Duration.seconds(2));
81106
await Agent.compileAfScript(conn, readFileSync(join(authoringBundleDir, `${!apiName}.agent`), 'utf8'));
82-
this.logSuccess('Successfully compiled');
107+
mso.updateData({ status: 'COMPLETED' });
108+
mso.stop('completed');
83109
return {
84110
success: true,
85111
};
86112
} catch (error) {
87113
// Handle validation errors
88114
const err = SfError.wrap(error);
115+
let count = 0;
89116
const formattedError = err.message
90117
.split('\n')
91-
.map((line) => `- ${line}`)
118+
.map((line) => {
119+
count += 1;
120+
const type = line.split(':')[0];
121+
const rest = line.substring(line.indexOf(':')).trim();
122+
return `- ${colorize('red', type)} ${rest}`;
123+
})
92124
.join('\n');
93-
this.error(messages.getMessage('error.compilationFailed', [formattedError]));
94125

126+
mso.updateData({ errors: count.toString(), status: 'ERROR' });
127+
mso.error();
128+
129+
this.log(messages.getMessage('error.compilationFailed', [formattedError]));
95130
return {
96131
success: false,
97132
errors: err.message.split('\n'),

0 commit comments

Comments
 (0)