UNPKG

salesforce-alm

Version:

This package contains tools, and APIs, for an improved salesforce.com developer experience.

95 lines (93 loc) 4.84 kB
"use strict"; /* * 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.OrgStatusCommand = void 0; const command_1 = require("@salesforce/command"); const core_1 = require("@salesforce/core"); const kit_1 = require("@salesforce/kit"); const sandboxOrg_1 = require("../../../lib/org/sandbox/sandboxOrg"); const sandboxProgressReporter_1 = require("../../../lib/org/sandbox/sandboxProgressReporter"); const consts = require("../../../lib/core/constants"); const sandboxConstants_1 = require("../../../lib/org/sandbox/sandboxConstants"); core_1.Messages.importMessagesDirectory(__dirname); const messages = core_1.Messages.loadMessages('salesforce-alm', 'org_status'); class OrgStatusCommand extends command_1.SfdxCommand { async run() { const alias = await core_1.Aliases.create({}); this.logger.debug('Status started with args %s ', this.flags); const masterProdOrg = this.org; const sandboxOrg = sandboxOrg_1.SandboxOrg.getInstance(masterProdOrg, this.flags.wait, this.logger, this.flags.clientid); // Keep all console output in the command sandboxOrg.on(sandboxConstants_1.SandboxEventNames.EVENT_STATUS, (results) => { sandboxProgressReporter_1.SandboxProgressReporter.logSandboxProgress(this.ux, results.sandboxProcessObj, results.interval, results.retries, results.waitingOnAuth); }); sandboxOrg.on(sandboxConstants_1.SandboxEventNames.EVENT_RESULT, (results) => { sandboxProgressReporter_1.SandboxProgressReporter.logSandboxProcessResult(this.ux, results.sandboxProcessObj, results.sandboxRes); if (results.sandboxRes && results.sandboxRes.authUserName) { if (this.flags.setalias) { const result = alias.set(this.flags.setalias, results.sandboxRes.authUserName); this.logger.debug('Set Alias: %s result: %s', this.flags.setalias, result); } if (this.flags.setdefaultusername) { const globalConfig = this.configAggregator.getGlobalConfig(); globalConfig.set(core_1.Config.DEFAULT_USERNAME, results.sandboxRes.authUserName); globalConfig .write() .then((result) => this.logger.debug('Set defaultUsername: %s result: %s', this.flags.setdefaultusername, result)); } } }); this.logger.debug('Calling auth for SandboxName args: %s ', this.flags.sandboxname); const results = await sandboxOrg.authWithRetriesByName(this.flags.sandboxname); this.logger.debug('Results for auth call: %s ', results); if (!results) { this.ux.styledHeader('Sandbox Org Creation Status'); this.ux.log('No SandboxProcess Result Found'); } return results; } } exports.OrgStatusCommand = OrgStatusCommand; OrgStatusCommand.longDescription = messages.getMessage('commandLongDescription'); OrgStatusCommand.help = messages.getMessage('commandHelp'); /* * TODO: When SfdxCommand change the messages for description to include both the description and the help messages * we have to remove the help from description. */ OrgStatusCommand.description = messages.getMessage('commandDescription') + '\n\n' + OrgStatusCommand.help; OrgStatusCommand.requiresProject = false; OrgStatusCommand.requiresUsername = true; OrgStatusCommand.flagsConfig = { sandboxname: command_1.flags.string({ char: 'n', description: messages.getMessage('sandboxnameFlagDescription'), longDescription: messages.getMessage('sandboxnameFlagLongDescription'), required: true, }), setdefaultusername: command_1.flags.boolean({ char: 's', description: messages.getMessage('setdefaultusernameFlagDescription'), longDescription: messages.getMessage('setdefaultusernameFlagLongDescription'), required: false, }), setalias: command_1.flags.string({ char: 'a', description: messages.getMessage('setaliasFlagDescription'), longDescription: messages.getMessage('setaliasFlagLongDescription'), required: false, }), wait: command_1.flags.minutes({ char: 'w', description: messages.getMessage('waitFlagDescription'), longDescription: messages.getMessage('waitFlagLongDescription'), required: false, min: kit_1.Duration.minutes(consts.MIN_STREAM_TIMEOUT_MINUTES), default: kit_1.Duration.minutes(consts.DEFAULT_STREAM_TIMEOUT_MINUTES), }), }; //# sourceMappingURL=status.js.map