UNPKG

cli-stash

Version:

CLI application to manage and work with Atlassian Stash. Work with your Stash project and repositories from Command lines.

67 lines (66 loc) 2.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@oclif/core"); const stash_connector_1 = require("stash-connector"); const baseCommand_1 = require("../../libs/core/baseCommand"); const stashResponse_1 = require("../../libs/core/stashResponse"); class Update extends baseCommand_1.BaseCommand { async run() { const response = new stashResponse_1.StashCLIResponse(); const connector = new stash_connector_1.StashConnector(this.localConfig.getConnectorOptions(this.flags.alias)); try { let inputData; if (this.hasInputData()) { inputData = this.getInputData(); } else { inputData = { password: this.flags.password, oldPassword: this.flags.old, passwordConfirm: this.flags.confirm, }; } await connector.users.changePassword(inputData); response.status = 0; response.message = this.getRecordUpdatedText('User Password'); this.ux.log(response.message); } catch (error) { this.processError(response, error); } return response; } } exports.default = Update; Update.description = 'Update the currently authenticated user\'s password.'; Update.examples = [ `$ stash users:credentials -a MyStashAlias --data "{'password':'newPass','passwordConfirm':'newPass','oldPassword':'oldPass'}" --json`, `$ stash users:credentials -a MyStashAlias --file "path/to/json/data/file"`, ]; Update.flags = { ...baseCommand_1.BaseCommand.flags, alias: baseCommand_1.BuildFlags.alias, data: baseCommand_1.BuildFlags.input.jsonData('<doc:ChangePasswordInput>', false, ['password', 'confirm', 'old']), file: baseCommand_1.BuildFlags.input.jsonFile('<doc:ChangePasswordInput>', false, ['password', 'confirm', 'old']), password: core_1.Flags.string({ description: 'The new password', required: false, name: 'Password', exclusive: ['data', 'file'], dependsOn: ['confirm', 'old'], }), confirm: core_1.Flags.string({ description: 'The new password confirm', required: false, name: 'Password', exclusive: ['data', 'file'], dependsOn: ['password', 'old'], }), old: core_1.Flags.string({ description: 'The old password', required: false, name: 'Password', exclusive: ['data', 'file'], dependsOn: ['password', 'confirm'], }), };