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

46 lines 2.01 kB
import { BaseCommand } from './BaseCommand.js'; import { logger } from '../services/logger.js'; import { parseBuildRef } from '../utils/parseBuildRef.js'; import { getArtifactFormatter } from '../formatters/artifacts/index.js'; import { formatError } from '../ui/theme.js'; import { Progress } from '../ui/progress.js'; import { parseScopeError, formatScopeError } from '../utils/scopeError.js'; export class ArtifactsList extends BaseCommand { static requiresToken = true; async execute(options) { const format = options.format || 'plain'; const spinner = Progress.spinner('Fetching artifacts...', { format }); try { this.token = await BaseCommand.getToken(options); const ref = parseBuildRef(options.buildRef); const artifacts = await this.restClient.listBuildArtifacts(ref.org, ref.pipeline, ref.number); spinner.stop(); const formatter = getArtifactFormatter(format); logger.console(formatter.formatArtifacts(artifacts)); return 0; } catch (error) { spinner.stop(); if (error instanceof Error) { const parsed = parseScopeError(error.message); if (parsed.matched) { const formatted = formatScopeError(parsed.scope); logger.console(formatError(formatted.message, { suggestions: formatted.suggestions })); } else { logger.console(formatError(error.message, { suggestions: [ 'Check the build reference format (org/pipeline/number or URL)', 'Run `bktide token --check` to verify token scopes', ], })); } } else { logger.error('Unknown error occurred'); } return 1; } } } //# sourceMappingURL=ArtifactsList.js.map