UNPKG

bktide

Version:

Command-line interface for Buildkite CI/CD workflows with rich shell completions (Fish, Bash, Zsh) and Alfred workflow integration for macOS power users

78 lines 2.89 kB
import { BaseCommand } from './BaseCommand.js'; import { parseBuildkiteReference } from '../utils/parseBuildkiteReference.js'; import { logger } from '../services/logger.js'; import { ShowBuild } from './ShowBuild.js'; import { ShowPipeline } from './ShowPipeline.js'; import { ShowLogs } from './ShowLogs.js'; import { formatError } from '../ui/theme.js'; export class SmartShow extends BaseCommand { static requiresToken = true; async execute(options) { if (options.debug) { logger.debug('Starting SmartShow command execution', options); } if (!options.reference) { logger.error('Reference is required'); return 1; } try { // Parse the reference const ref = parseBuildkiteReference(options.reference); if (options.debug) { logger.debug('Parsed reference:', ref); } // Route based on reference type switch (ref.type) { case 'pipeline': return await this.showPipeline(ref, options); case 'build': return await this.showBuild(ref, options); case 'build-with-step': return await this.showBuildWithStep(ref, options); default: logger.error('Unknown reference type'); return 1; } } catch (error) { if (error instanceof Error) { const errorOutput = formatError(error.message, { suggestions: ['Check the reference format', 'Verify you have access to this resource'], }); logger.console(errorOutput); } else { logger.error('Unknown error occurred'); } return 1; } } async showPipeline(ref, options) { const pipelineCommand = new ShowPipeline(); return await pipelineCommand.execute({ ...options, reference: `${ref.org}/${ref.pipeline}`, count: 20, // Default for smart references }); } async showBuild(ref, options) { // Route to ShowBuild with enhanced defaults (--jobs --failed) const buildCommand = new ShowBuild(options); const buildOptions = { ...options, buildArg: `${ref.org}/${ref.pipeline}/${ref.buildNumber}`, jobs: true, failed: true, }; return await buildCommand.execute(buildOptions); } async showBuildWithStep(ref, options) { const logsCommand = new ShowLogs(); return await logsCommand.execute({ ...options, buildRef: `${ref.org}/${ref.pipeline}/${ref.buildNumber}`, stepId: ref.stepId, }); } } //# sourceMappingURL=SmartShow.js.map