UNPKG

@mondaycom/apps-cli

Version:

A cli tool to manage apps (and monday-code projects) in monday.com

59 lines (58 loc) 2.51 kB
import { Flags } from '@oclif/core'; import { AuthenticatedCommand } from '../../commands-base/authenticated-command.js'; import { APP_ID_TO_ENTER, APP_VERSION_ID_TO_ENTER } from '../../consts/messages.js'; import { DynamicChoicesService } from '../../services/dynamic-choices-service.js'; import { listAppFeaturesByAppVersionId } from '../../services/app-features-service.js'; import logger from '../../utils/logger.js'; const printAppFeatures = (appFeatures) => { logger.table(appFeatures); }; export default class AppFeatureList extends AuthenticatedCommand { static description = 'List all features for a specific app version.'; static examples = ['<%= config.bin %> <%= command.id %> -a APP_ID -i APP_VERSION_ID']; static flags = AppFeatureList.serializeFlags({ appId: Flags.integer({ char: 'a', aliases: ['appId'], description: APP_ID_TO_ENTER, }), appVersionId: Flags.integer({ char: 'i', aliases: ['versionId'], description: APP_VERSION_ID_TO_ENTER, }), }); DEBUG_TAG = 'app_feature_list'; async run() { const { flags } = await this.parse(AppFeatureList); const appId = flags.appId; let appVersionId = flags.appVersionId; if (!appVersionId) { const appIdAndAppVersionId = await DynamicChoicesService.chooseAppAndAppVersion(true, true, { appId, autoSelectVersion: false, }); appVersionId = Number(appIdAndAppVersionId.appVersionId); } this.preparePrintCommand(this, { appId, appVersionId }); const appFeatures = await listAppFeaturesByAppVersionId(appVersionId); if (!appFeatures || appFeatures.length === 0) { logger.error(`No app features found for provided app version id - "${appVersionId}"`); return process.exit(0); } const printableAppFeatures = appFeatures.map(appFeature => { const build = appFeature.current_release?.data?.url || appFeature.data?.microFrontendName || appFeature.current_release?.data?.microFrontendName || 'N/A'; return { id: appFeature.id, name: appFeature.name, type: appFeature.type, status: appFeature.status || 'active', build, }; }); printAppFeatures(printableAppFeatures); } }