UNPKG

@broadcom/endevor-bridge-for-git-for-zowe-cli

Version:

Endevor Bridge for Git plug-in for Zowe CLI

71 lines (66 loc) 2.92 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var BaseHandler = require('../../../BaseHandler.js'); var BranchOptions = require('../../../options/BranchOptions.js'); var MappingUtils = require('../../../../api/utils/MappingUtils.js'); /* * Copyright (c) 2026 Broadcom. All Rights Reserved. The term * "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This software and all information contained therein is * confidential and proprietary and shall not be duplicated, * used, disclosed, or disseminated in any way except as * authorized by the applicable license agreement, without the * express written permission of Broadcom. All authorized * reproductions must be marked with this language. * * EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO * THE EXTENT PERMITTED BY APPLICABLE LAW, BROADCOM PROVIDES THIS * SOFTWARE WITHOUT WARRANTY OF ANY KIND, INCLUDING WITHOUT * LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL BROADCOM * BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR * DAMAGE, DIRECT OR INDIRECT, FROM THE USE OF THIS SOFTWARE, * INCLUDING WITHOUT LIMITATION, LOST PROFITS, BUSINESS * INTERRUPTION, GOODWILL, OR LOST DATA, EVEN IF BROADCOM IS * EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE. * */ class ListBranchHandler extends BaseHandler.BaseHandler { static FIELDS = [ "branchId", "endevorUserName", "environment", "system", "subsystem", "stage", "readOnly", "mappingMode", "queueStatus", ]; async processWithSession() { const context = this.getOption(BranchOptions.BranchOptions.CONTEXT, true); const repoName = this.getOption(BranchOptions.BranchOptions.MAPPING, true); this.validateRequiredOptions(); const mapping = await MappingUtils.MappingUtils.getMapping(this.apiClient, context, repoName); const branches = mapping.branches; const output = []; branches?.forEach((branch) => { const isMultiSys = MappingUtils.MappingUtils.isMultiSystem(branch); const branchView = { branchId: branch.branchId, endevorUserName: branch.endevorUserName ?? undefined, environment: branch.environment, system: isMultiSys ? "multi" : branch.systems[0].name, subsystem: isMultiSys ? "multi" : branch.systems[0].subsystems[0].name, stage: branch.stage, readOnly: String(branch.readOnly), mappingMode: branch.mappingMode.value, queueStatus: branch.queueStatus?.value ?? undefined, }; output.push(branchView); }); this.setOutput("table", output, ListBranchHandler.FIELDS, true); } } exports.default = ListBranchHandler;