sfdx-hardis
Version:
Swiss-army-knife Toolbox for Salesforce. Allows you to define a complete CD/CD Pipeline. Orchestrate base commands and assist users with interactive wizards
35 lines • 1.74 kB
JavaScript
import { ActionsProvider } from './actionsProvider.js';
import { execCommand, uxLog } from '../utils/index.js';
import fs from 'fs-extra';
import c from 'chalk';
export class ApexAction extends ActionsProvider {
getLabel() {
return 'ApexAction';
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async checkParameters(cmd) {
const apexScript = cmd.parameters?.apexScript || '';
if (!apexScript) {
uxLog('error', this, c.red(`[DeploymentActions] No apexScript parameter provided for action [${cmd.id}]: ${cmd.label}`));
return { statusCode: 'failed', skippedReason: 'No apexScript parameter provided' };
}
if (!fs.existsSync(apexScript)) {
uxLog('error', this, c.red(`[DeploymentActions] Apex script file ${apexScript} does not exist for action [${cmd.id}]: ${cmd.label}`));
return { statusCode: 'failed', skippedReason: `Apex script file ${apexScript} does not exist` };
}
return null;
}
async run(cmd) {
const validity = await this.checkValidityIssues(cmd);
if (validity)
return validity;
const apexScript = cmd.parameters?.apexScript || '';
const apexCommand = `sf apex run --file ${apexScript}` + (this.customUsernameToUse ? ` --target-org ${this.customUsernameToUse}` : '');
const res = await execCommand(apexCommand, null, { fail: false, output: true });
if (res.status === 0) {
return { statusCode: 'success', output: (res.stdout || '') + '\n' + (res.stderr || '') };
}
return { statusCode: 'failed', output: (res.stdout || '') + '\n' + (res.stderr || '') };
}
}
//# sourceMappingURL=apexAction.js.map