salesforce-alm
Version:
This package contains tools, and APIs, for an improved salesforce.com developer experience.
51 lines (49 loc) • 2.09 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.OrgShapeDeleteCommand = void 0;
const os_1 = require("os");
const command_1 = require("@salesforce/command");
const core_1 = require("@salesforce/core");
const shapeRepApi_1 = require("../../../../lib/org/shapeRepApi");
const almError = require("../../../../lib/core/almError");
core_1.Messages.importMessagesDirectory(__dirname);
const messages = core_1.Messages.loadMessages('salesforce-alm', 'org_shape_delete');
class OrgShapeDeleteCommand extends command_1.SfdxCommand {
async run() {
if (!this.flags.noprompt) {
if (!(await this.ux.confirm(messages.getMessage('deleteCommandYesNo', [this.org.getUsername()])))) {
return;
}
}
const api = new shapeRepApi_1.ShapeRepresentationApi(this.org);
if (!(await api.isFeatureEnabled())) {
throw almError({ keyName: 'noAccess', bundle: 'org_shape_delete' }, [this.org.getUsername()]);
}
const deletedShapesIds = await api.deleteAll();
if (deletedShapesIds.length === 0) {
this.ux.log(messages.getMessage('noShapesHumanSuccess', [this.org.getOrgId()]));
}
this.ux.log(messages.getMessage('humanSuccess', [this.org.getOrgId()]));
return {
orgId: this.org.getOrgId(),
shapeIds: deletedShapesIds,
};
}
}
exports.OrgShapeDeleteCommand = OrgShapeDeleteCommand;
OrgShapeDeleteCommand.description = messages.getMessage('description');
OrgShapeDeleteCommand.examples = messages.getMessage('help').split(os_1.EOL);
OrgShapeDeleteCommand.requiresUsername = true;
OrgShapeDeleteCommand.flagsConfig = {
noprompt: command_1.flags.boolean({
char: 'p',
description: messages.getMessage('noPrompt'),
}),
};
//# sourceMappingURL=delete.js.map