salesforcedx-templates
Version:
Salesforce CLI scaffolding commands for different types of Force.com metadata
58 lines • 2.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/*
* Copyright (c) 2019, 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
*/
const core_1 = require("@salesforce/core");
core_1.Messages.importMessagesDirectory(__dirname);
// TODO: Update util when sfdxdocgen is updated to support oclif
class MessageUtil {
/**
* Get the message for a given key
* @param key The key of the message
* @param tokens The values to substitute in the message
*/
static get(key, tokens) {
return this.messages.getMessage(key, tokens);
}
/**
* Get the description used in the --help output for the command
* @param descriptionKey The message key for the description text
* @param isLightningBundle If the command is for a lightning bundle
* @param tokens The values to substitute in the message
* @param extra Extra text to append to the description at the end
*/
static buildDescription(descriptionKey, isLightningBundle, tokens, extra) {
return (this.messages.getMessage(descriptionKey, tokens) +
'\n' +
this.getHelpHead(isLightningBundle) +
(extra || ''));
}
/**
* Get the help text displayed in site documentation for the command
*
* **USE `buildDescription` FOR SETTING THE `description` PROPERTY OF
* A COMMAND. THIS IS EXCLUSIVELY USED TO SET THE `help` PROPERTY ON THE COMMAND FOR
* DOC GENERATING PURPOSES AND IS NOT SHOWN IN THE --help OUTPUT.**
* @param examples Example uses of the command
* @param isLightningBundle If the command is for a lightning bundle
* @param extra Extra text to append to the help message before the examples
*/
static buildHelpText(examples, isLightningBundle, extra) {
return (this.getHelpHead(isLightningBundle) +
(extra || '') +
this.messages.getMessage('HelpExamplesTitle') +
examples.reduce((acc, current) => acc + ` ${current}\n`, ''));
}
static getHelpHead(isLightning) {
return (this.messages.getMessage('HelpDefaults') +
this.messages.getMessage('HelpOutputDirRelative') +
(isLightning ? MessageUtil.get('HelpOutputDirRelativeLightning') : ''));
}
}
MessageUtil.messages = core_1.Messages.loadMessages('salesforcedx-templates', 'messages');
exports.MessageUtil = MessageUtil;
//# sourceMappingURL=messageUtil.js.map