UNPKG

@pnp/cli-microsoft365

Version:

Manage Microsoft 365 and SharePoint Framework projects on any platform

59 lines 2.84 kB
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _ConnectionSetCommand_instances, _ConnectionSetCommand_initOptions, _ConnectionSetCommand_initValidators, _ConnectionSetCommand_initTypes; import auth from '../../../Auth.js'; import commands from '../commands.js'; import Command, { CommandError } from '../../../Command.js'; class ConnectionSetCommand extends Command { get name() { return commands.SET; } get description() { return 'Rename the specified connection'; } constructor() { super(); _ConnectionSetCommand_instances.add(this); __classPrivateFieldGet(this, _ConnectionSetCommand_instances, "m", _ConnectionSetCommand_initOptions).call(this); __classPrivateFieldGet(this, _ConnectionSetCommand_instances, "m", _ConnectionSetCommand_initValidators).call(this); __classPrivateFieldGet(this, _ConnectionSetCommand_instances, "m", _ConnectionSetCommand_initTypes).call(this); } async commandAction(logger, args) { const connection = await auth.getConnection(args.options.name); if (this.verbose) { await logger.logToStderr(`Updating connection '${connection.identityName}', appId: ${connection.appId}, tenantId: ${connection.identityTenantId}...`); } await auth.updateConnection(connection, args.options.newName); } async action(logger, args) { try { await auth.restoreAuth(); } catch (error) { throw new CommandError(error); } await this.initAction(args, logger); await this.commandAction(logger, args); } } _ConnectionSetCommand_instances = new WeakSet(), _ConnectionSetCommand_initOptions = function _ConnectionSetCommand_initOptions() { this.options.unshift({ option: '-n, --name <name>' }, { option: '--newName <newName>' }); }, _ConnectionSetCommand_initValidators = function _ConnectionSetCommand_initValidators() { this.validators.push(async (args) => { if (args.options.name === args.options.newName) { return `Choose a name different from the current one`; } return true; }); }, _ConnectionSetCommand_initTypes = function _ConnectionSetCommand_initTypes() { this.types.string.push('name', 'newName'); }; export default new ConnectionSetCommand(); //# sourceMappingURL=connection-set.js.map