salesforce-alm
Version:
This package contains tools, and APIs, for an improved salesforce.com developer experience.
63 lines (61 loc) • 3.3 kB
JavaScript
;
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SandboxProgressReporter = void 0;
const kit_1 = require("@salesforce/kit");
class SandboxProgressReporter {
static logSandboxProcessResult(ux, processRecord, sandboxRes) {
if (processRecord) {
let resultMsg = `Sandbox ${processRecord.SandboxName}(${processRecord.Id}) is ready for use.`;
ux.log(resultMsg);
const data = [
{ key: 'Id', value: processRecord.Id },
{ key: 'SandboxName', value: processRecord.SandboxName },
{ key: 'Status', value: processRecord.Status },
{ key: 'CopyProgress', value: processRecord.CopyProgress },
{ key: 'Description', value: processRecord.Description },
{ key: 'LicenseType', value: processRecord.LicenseType },
{ key: 'SandboxInfoId', value: processRecord.SandboxInfoId },
{ key: 'SourceId', value: processRecord.SourceId },
{ key: 'SandboxOrg', value: processRecord.SandboxOrganization },
{ key: 'Created Date', value: processRecord.CreatedDate },
{ key: 'ApexClassId', value: processRecord.ApexClassId },
{ key: 'Authorized Sandbox Username', value: sandboxRes.authUserName },
];
ux.styledHeader('Sandbox Org Creation Status');
ux.table(data, {
columns: [
{ key: 'key', label: 'Name' },
{ key: 'value', label: 'Value' },
],
});
}
}
static logSandboxProgress(ux, processRecord, pollIntervalInSecond, retriesLeft, waitingOnAuth) {
let progressMsg;
let waitTimeInSec = retriesLeft * pollIntervalInSecond;
let waitTime = SandboxProgressReporter.getSecondsToHms(waitTimeInSec);
let waitTimeMsg = `Sleeping ${pollIntervalInSecond} seconds. Will wait ${waitTime} more before timing out.`;
let sandboxIdentifierMsg = `${processRecord.SandboxName}(${processRecord.Id})`;
let waitingOnAuthMessage = waitingOnAuth ? ', waiting on JWT auth' : '';
let completionMessage = `(${processRecord.CopyProgress}% completed${waitingOnAuthMessage})`;
progressMsg = `Sandbox request ${sandboxIdentifierMsg} is ${processRecord.Status} ${completionMessage}. ${waitTimeMsg}`;
ux.log(progressMsg);
}
static getSecondsToHms(waitTimeInSec) {
let h = kit_1.Duration.hours(Math.floor(waitTimeInSec / 3600));
let m = kit_1.Duration.minutes(Math.floor((waitTimeInSec % 3600) / 60));
let s = kit_1.Duration.seconds(Math.floor(waitTimeInSec % 60));
let hDisplay = h.hours > 0 ? h.toString() + ' ' : '';
let mDisplay = m.minutes > 0 ? m.toString() + ' ' : '';
let sDisplay = s.seconds > 0 ? s.toString() : '';
return (hDisplay + mDisplay + sDisplay).trim();
}
}
exports.SandboxProgressReporter = SandboxProgressReporter;
//# sourceMappingURL=sandboxProgressReporter.js.map