salesforce-alm
Version:
This package contains tools, and APIs, for an improved salesforce.com developer experience.
82 lines (80 loc) • 3.86 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.CommunityCreateCommand = void 0;
const command_1 = require("@salesforce/command");
const core_1 = require("@salesforce/core");
const CommunityNameValueParser_1 = require("../../../lib/community/commands/CommunityNameValueParser");
const ConnectExecutor_1 = require("../../../lib/connect/services/ConnectExecutor");
const CommunityCreateResource_1 = require("../../../lib/community/connect/CommunityCreateResource");
core_1.Messages.importMessagesDirectory(__dirname);
const communityMessages = core_1.Messages.loadMessages('salesforce-alm', 'community_commands');
/**
* A command to create a community.
* This is just an sfdx wrapper around the community create connect endpoint
*/
class CommunityCreateCommand extends command_1.SfdxCommand {
parseVarargs(args) {
this.logger.debug('parseVarargs(' + args + ')');
// It never looks like args is ever undefined as long as varargs is turned on for the command...
// But since the signature says it's optional, we should probably gate this even though it's unnecessary right now.
if (args === undefined) {
return {};
}
const parser = new CommunityNameValueParser_1.CommunityNameValueParser(CommunityCreateCommand.validationPatterns);
const values = parser.parse(args);
this.logger.debug('parseVarargs result:' + JSON.stringify(values));
return values;
}
async run() {
const createCommand = new CommunityCreateResource_1.CommunityCreateResource(this.flags, this.varargs, this.ux);
return new ConnectExecutor_1.ConnectExecutor(createCommand, this.org).callConnectApi();
}
}
exports.CommunityCreateCommand = CommunityCreateCommand;
CommunityCreateCommand.requiresUsername = true;
CommunityCreateCommand.varargs = true;
CommunityCreateCommand.help = communityMessages.getMessage('create.help');
CommunityCreateCommand.longDescription = communityMessages.getMessage('create.longDescription');
CommunityCreateCommand.description = communityMessages.getMessage('create.description') + '\n\n' + CommunityCreateCommand.help;
CommunityCreateCommand.flagsConfig = {
name: command_1.flags.string({
char: 'n',
description: communityMessages.getMessage('create.flags.name.description'),
longDescription: communityMessages.getMessage('create.flags.name.longDescription'),
required: true,
}),
templatename: command_1.flags.string({
char: 't',
description: communityMessages.getMessage('create.flags.templateName.description'),
longDescription: communityMessages.getMessage('create.flags.templateName.longDescription'),
required: true,
}),
urlpathprefix: command_1.flags.string({
char: 'p',
description: communityMessages.getMessage('create.flags.urlPathPrefix.description'),
longDescription: communityMessages.getMessage('create.flags.urlPathPrefix.longDescription'),
required: true,
}),
description: command_1.flags.string({
char: 'd',
description: communityMessages.getMessage('create.flags.description.description'),
longDescription: communityMessages.getMessage('create.flags.description.longDescription'),
required: false,
}),
};
CommunityCreateCommand.validationPatterns = [
// Exact matches
'name',
'urlPathPrefix',
'templateName',
'description',
// templateParams.*, but must be only word characters (e.g. no spaces, special chars)
'templateParams(\\.\\w+)+',
];
//# sourceMappingURL=create.js.map