bktide 1.0.1769033899 → 1.0.1769039233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/dist/commands/ShowLogs.js +156 -0
- package/dist/commands/ShowLogs.js.map +1 -0
- package/dist/commands/ShowPipeline.js +92 -0
- package/dist/commands/ShowPipeline.js.map +1 -0
- package/dist/commands/SmartShow.js +15 -187
- package/dist/commands/SmartShow.js.map +1 -1
- package/dist/commands/index.js +2 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/index.js +67 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,6 +193,44 @@ bktide build org/pipeline/123 --annotations
|
|
|
193
193
|
bktide build org/pipeline/123 --jobs --failed --annotations
|
|
194
194
|
```
|
|
195
195
|
|
|
196
|
+
### Show Pipeline Details
|
|
197
|
+
|
|
198
|
+
View pipeline metadata and recent builds.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# View pipeline by slug format
|
|
202
|
+
bktide pipeline org/pipeline
|
|
203
|
+
|
|
204
|
+
# View pipeline by URL format
|
|
205
|
+
bktide pipeline https://buildkite.com/org/pipeline
|
|
206
|
+
|
|
207
|
+
# Show more recent builds
|
|
208
|
+
bktide pipeline org/pipeline --count 50
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### View Step Logs
|
|
212
|
+
|
|
213
|
+
View logs for a specific build step.
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# View logs by providing build reference and step ID
|
|
217
|
+
bktide logs org/pipeline/123 <step-id>
|
|
218
|
+
|
|
219
|
+
# View logs from URL with step ID in query parameter
|
|
220
|
+
bktide logs "https://buildkite.com/org/pipeline/builds/123?sid=<step-id>"
|
|
221
|
+
|
|
222
|
+
# Show all lines (default is last 50 lines)
|
|
223
|
+
bktide logs org/pipeline/123 <step-id> --full
|
|
224
|
+
|
|
225
|
+
# Show last N lines
|
|
226
|
+
bktide logs org/pipeline/123 <step-id> --lines 100
|
|
227
|
+
|
|
228
|
+
# Save logs to file
|
|
229
|
+
bktide logs org/pipeline/123 <step-id> --save logs.txt
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Note:** Viewing step logs requires `read_build_logs` scope on your API token.
|
|
233
|
+
|
|
196
234
|
### Smart Reference Command
|
|
197
235
|
|
|
198
236
|
Paste any Buildkite URL or use short-hand formats, and bktide will figure out what to show.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { BaseCommand } from './BaseCommand.js';
|
|
2
|
+
import { logger } from '../services/logger.js';
|
|
3
|
+
import { parseBuildkiteReference } from '../utils/parseBuildkiteReference.js';
|
|
4
|
+
import { PlainStepLogsFormatter, JsonStepLogsFormatter, AlfredStepLogsFormatter } from '../formatters/step-logs/index.js';
|
|
5
|
+
import { SEMANTIC_COLORS, formatError } from '../ui/theme.js';
|
|
6
|
+
import { Progress } from '../ui/progress.js';
|
|
7
|
+
import * as fs from 'fs/promises';
|
|
8
|
+
export class ShowLogs extends BaseCommand {
|
|
9
|
+
static requiresToken = true;
|
|
10
|
+
async execute(options) {
|
|
11
|
+
if (options.debug) {
|
|
12
|
+
logger.debug('Starting ShowLogs command execution', options);
|
|
13
|
+
}
|
|
14
|
+
if (!options.buildRef) {
|
|
15
|
+
logger.error('Build reference is required');
|
|
16
|
+
return 1;
|
|
17
|
+
}
|
|
18
|
+
const format = options.format || 'plain';
|
|
19
|
+
const spinner = Progress.spinner('Fetching step logs...', { format });
|
|
20
|
+
try {
|
|
21
|
+
// Initialize token first
|
|
22
|
+
this.token = await BaseCommand.getToken(options);
|
|
23
|
+
// Parse the reference to extract org/pipeline/build and possibly stepId
|
|
24
|
+
const ref = parseBuildkiteReference(options.buildRef);
|
|
25
|
+
// Determine stepId - could come from argument, URL query param, or reference
|
|
26
|
+
let stepId = options.stepId;
|
|
27
|
+
if (!stepId && ref.type === 'build-with-step') {
|
|
28
|
+
stepId = ref.stepId;
|
|
29
|
+
}
|
|
30
|
+
if (!stepId) {
|
|
31
|
+
spinner.stop();
|
|
32
|
+
logger.error('Step ID is required. Provide it as an argument or include ?sid= in the URL');
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
// Validate reference type
|
|
36
|
+
if (ref.type !== 'build' && ref.type !== 'build-with-step') {
|
|
37
|
+
spinner.stop();
|
|
38
|
+
logger.error('Invalid build reference. Expected format: org/pipeline/build or URL with build');
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
// Use REST API to get build with jobs (step.id field needed for matching)
|
|
42
|
+
const build = await this.restClient.getBuild(ref.org, ref.pipeline, ref.buildNumber);
|
|
43
|
+
const jobs = build.jobs || [];
|
|
44
|
+
if (!jobs || jobs.length === 0) {
|
|
45
|
+
spinner.stop();
|
|
46
|
+
logger.error(`Build not found: ${ref.org}/${ref.pipeline}/${ref.buildNumber}`);
|
|
47
|
+
return 1;
|
|
48
|
+
}
|
|
49
|
+
// Find job by step ID (sid from URL) - step.id is different from job.id
|
|
50
|
+
if (options.debug) {
|
|
51
|
+
logger.debug(`Found ${jobs.length} jobs in build`);
|
|
52
|
+
logger.debug(`Looking for step ID: ${stepId}`);
|
|
53
|
+
// Log first few jobs for debugging
|
|
54
|
+
jobs.slice(0, 3).forEach((j) => {
|
|
55
|
+
logger.debug(` Job: id=${j.id}, step.id=${j.step?.id}, name=${j.name}`);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const job = jobs.find((j) => j.step?.id === stepId);
|
|
59
|
+
if (!job) {
|
|
60
|
+
spinner.stop();
|
|
61
|
+
logger.error(`Step not found in build #${ref.buildNumber}: ${stepId}`);
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
// Use job.id (job UUID) for log fetching, not stepId
|
|
65
|
+
const logData = await this.restClient.getJobLog(ref.org, ref.pipeline, ref.buildNumber, job.id);
|
|
66
|
+
spinner.stop();
|
|
67
|
+
// Parse log content
|
|
68
|
+
const logLines = logData.content.split('\n');
|
|
69
|
+
const totalLines = logLines.length;
|
|
70
|
+
// Determine how many lines to display
|
|
71
|
+
const linesToShow = options.full ? totalLines : (options.lines || 50);
|
|
72
|
+
const startLine = Math.max(0, totalLines - linesToShow);
|
|
73
|
+
const displayedLines = logLines.slice(startLine);
|
|
74
|
+
// Save to file if requested
|
|
75
|
+
if (options.save) {
|
|
76
|
+
await fs.writeFile(options.save, logData.content);
|
|
77
|
+
logger.console(SEMANTIC_COLORS.success(`✓ Log saved to ${options.save} (${this.formatSize(logData.size)}, ${totalLines} lines)`));
|
|
78
|
+
}
|
|
79
|
+
// Prepare data for formatter using REST API fields from build object
|
|
80
|
+
const data = {
|
|
81
|
+
build: {
|
|
82
|
+
org: ref.org,
|
|
83
|
+
pipeline: ref.pipeline,
|
|
84
|
+
number: ref.buildNumber,
|
|
85
|
+
state: build.state || 'unknown',
|
|
86
|
+
startedAt: build.started_at,
|
|
87
|
+
finishedAt: build.finished_at,
|
|
88
|
+
url: build.web_url,
|
|
89
|
+
},
|
|
90
|
+
step: {
|
|
91
|
+
id: job.id,
|
|
92
|
+
label: job.name,
|
|
93
|
+
state: job.state,
|
|
94
|
+
exitStatus: job.exit_status,
|
|
95
|
+
startedAt: job.started_at,
|
|
96
|
+
finishedAt: job.finished_at,
|
|
97
|
+
},
|
|
98
|
+
logs: {
|
|
99
|
+
content: displayedLines.join('\n'),
|
|
100
|
+
size: logData.size,
|
|
101
|
+
totalLines,
|
|
102
|
+
displayedLines: displayedLines.length,
|
|
103
|
+
startLine,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
// Format and display (unless only saving)
|
|
107
|
+
if (!options.save || options.format) {
|
|
108
|
+
let formatter;
|
|
109
|
+
if (format === 'alfred') {
|
|
110
|
+
formatter = new AlfredStepLogsFormatter({ full: options.full, lines: options.lines });
|
|
111
|
+
}
|
|
112
|
+
else if (format === 'json') {
|
|
113
|
+
formatter = new JsonStepLogsFormatter({ full: options.full, lines: options.lines });
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
formatter = new PlainStepLogsFormatter({ full: options.full, lines: options.lines });
|
|
117
|
+
}
|
|
118
|
+
const output = formatter.format(data);
|
|
119
|
+
logger.console(output);
|
|
120
|
+
}
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
spinner.stop();
|
|
125
|
+
if (error instanceof Error) {
|
|
126
|
+
if (error.message.includes('401') || error.message.includes('403')) {
|
|
127
|
+
const errorOutput = formatError('Permission denied', {
|
|
128
|
+
suggestions: [
|
|
129
|
+
'Your API token needs \'read_build_logs\' scope to view logs',
|
|
130
|
+
'Update your token at: https://buildkite.com/user/api-access-tokens',
|
|
131
|
+
],
|
|
132
|
+
});
|
|
133
|
+
logger.console(errorOutput);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const errorOutput = formatError(error.message, {
|
|
137
|
+
suggestions: ['Check the reference format', 'Verify you have access to this resource'],
|
|
138
|
+
});
|
|
139
|
+
logger.console(errorOutput);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
logger.error('Unknown error occurred');
|
|
144
|
+
}
|
|
145
|
+
return 1;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
formatSize(bytes) {
|
|
149
|
+
if (bytes < 1024)
|
|
150
|
+
return `${bytes} B`;
|
|
151
|
+
if (bytes < 1024 * 1024)
|
|
152
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
153
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=ShowLogs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShowLogs.js","sourceRoot":"/","sources":["commands/ShowLogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAsB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,M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ACH,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,KAAa;QAC9B,IAAI,KAAK,GAAG,IAAI;YAAE,OAAO,GAAG,KAAK,IAAI,CAAC;QACtC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;YAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QAClE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IACpD,CAAC","sourcesContent":["import { BaseCommand, BaseCommandOptions } from './BaseCommand.js';\nimport { logger } from '../services/logger.js';\nimport { parseBuildkiteReference } from '../utils/parseBuildkiteReference.js';\nimport { PlainStepLogsFormatter, JsonStepLogsFormatter, AlfredStepLogsFormatter } from '../formatters/step-logs/index.js';\nimport type { StepLogsData } from '../formatters/step-logs/Formatter.js';\nimport { SEMANTIC_COLORS, formatError } from '../ui/theme.js';\nimport { Progress } from '../ui/progress.js';\nimport * as fs from 'fs/promises';\n\nexport interface ShowLogsOptions extends BaseCommandOptions {\n buildRef: string;\n stepId?: string;\n full?: boolean;\n lines?: number;\n save?: string;\n}\n\nexport class ShowLogs extends BaseCommand {\n static requiresToken = true;\n\n async execute(options: ShowLogsOptions): Promise<number> {\n if (options.debug) {\n logger.debug('Starting ShowLogs command execution', options);\n }\n\n if (!options.buildRef) {\n logger.error('Build reference is required');\n return 1;\n }\n\n const format = options.format || 'plain';\n const spinner = Progress.spinner('Fetching step logs...', { format });\n\n try {\n // Initialize token first\n this.token = await BaseCommand.getToken(options);\n\n // Parse the reference to extract org/pipeline/build and possibly stepId\n const ref = parseBuildkiteReference(options.buildRef);\n\n // Determine stepId - could come from argument, URL query param, or reference\n let stepId = options.stepId;\n if (!stepId && ref.type === 'build-with-step') {\n stepId = ref.stepId;\n }\n\n if (!stepId) {\n spinner.stop();\n logger.error('Step ID is required. Provide it as an argument or include ?sid= in the URL');\n return 1;\n }\n\n // Validate reference type\n if (ref.type !== 'build' && ref.type !== 'build-with-step') {\n spinner.stop();\n logger.error('Invalid build reference. Expected format: org/pipeline/build or URL with build');\n return 1;\n }\n\n // Use REST API to get build with jobs (step.id field needed for matching)\n const build = await this.restClient.getBuild(ref.org, ref.pipeline, ref.buildNumber);\n const jobs = build.jobs || [];\n\n if (!jobs || jobs.length === 0) {\n spinner.stop();\n logger.error(`Build not found: ${ref.org}/${ref.pipeline}/${ref.buildNumber}`);\n return 1;\n }\n\n // Find job by step ID (sid from URL) - step.id is different from job.id\n if (options.debug) {\n logger.debug(`Found ${jobs.length} jobs in build`);\n logger.debug(`Looking for step ID: ${stepId}`);\n // Log first few jobs for debugging\n jobs.slice(0, 3).forEach((j: any) => {\n logger.debug(` Job: id=${j.id}, step.id=${j.step?.id}, name=${j.name}`);\n });\n }\n const job = jobs.find((j: any) => j.step?.id === stepId);\n\n if (!job) {\n spinner.stop();\n logger.error(`Step not found in build #${ref.buildNumber}: ${stepId}`);\n return 1;\n }\n\n // Use job.id (job UUID) for log fetching, not stepId\n const logData = await this.restClient.getJobLog(ref.org, ref.pipeline, ref.buildNumber, job.id);\n spinner.stop();\n\n // Parse log content\n const logLines = logData.content.split('\\n');\n const totalLines = logLines.length;\n\n // Determine how many lines to display\n const linesToShow = options.full ? totalLines : (options.lines || 50);\n const startLine = Math.max(0, totalLines - linesToShow);\n const displayedLines = logLines.slice(startLine);\n\n // Save to file if requested\n if (options.save) {\n await fs.writeFile(options.save, logData.content);\n logger.console(SEMANTIC_COLORS.success(`✓ Log saved to ${options.save} (${this.formatSize(logData.size)}, ${totalLines} lines)`));\n }\n\n // Prepare data for formatter using REST API fields from build object\n const data: StepLogsData = {\n build: {\n org: ref.org,\n pipeline: ref.pipeline,\n number: ref.buildNumber,\n state: build.state || 'unknown',\n startedAt: build.started_at,\n finishedAt: build.finished_at,\n url: build.web_url,\n },\n step: {\n id: job.id,\n label: job.name,\n state: job.state,\n exitStatus: job.exit_status,\n startedAt: job.started_at,\n finishedAt: job.finished_at,\n },\n logs: {\n content: displayedLines.join('\\n'),\n size: logData.size,\n totalLines,\n displayedLines: displayedLines.length,\n startLine,\n },\n };\n\n // Format and display (unless only saving)\n if (!options.save || options.format) {\n let formatter;\n\n if (format === 'alfred') {\n formatter = new AlfredStepLogsFormatter({ full: options.full, lines: options.lines });\n } else if (format === 'json') {\n formatter = new JsonStepLogsFormatter({ full: options.full, lines: options.lines });\n } else {\n formatter = new PlainStepLogsFormatter({ full: options.full, lines: options.lines });\n }\n\n const output = formatter.format(data);\n logger.console(output);\n }\n\n return 0;\n } catch (error) {\n spinner.stop();\n if (error instanceof Error) {\n if (error.message.includes('401') || error.message.includes('403')) {\n const errorOutput = formatError('Permission denied', {\n suggestions: [\n 'Your API token needs \\'read_build_logs\\' scope to view logs',\n 'Update your token at: https://buildkite.com/user/api-access-tokens',\n ],\n });\n logger.console(errorOutput);\n } else {\n const errorOutput = formatError(error.message, {\n suggestions: ['Check the reference format', 'Verify you have access to this resource'],\n });\n logger.console(errorOutput);\n }\n } else {\n logger.error('Unknown error occurred');\n }\n return 1;\n }\n }\n\n private formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n }\n}\n"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { BaseCommand } from './BaseCommand.js';
|
|
2
|
+
import { logger } from '../services/logger.js';
|
|
3
|
+
import { parseBuildkiteReference } from '../utils/parseBuildkiteReference.js';
|
|
4
|
+
import { PlainPipelineDetailFormatter, JsonPipelineDetailFormatter, AlfredPipelineDetailFormatter } from '../formatters/pipeline-detail/index.js';
|
|
5
|
+
import { formatError } from '../ui/theme.js';
|
|
6
|
+
import { Progress } from '../ui/progress.js';
|
|
7
|
+
export class ShowPipeline extends BaseCommand {
|
|
8
|
+
static requiresToken = true;
|
|
9
|
+
async execute(options) {
|
|
10
|
+
if (options.debug) {
|
|
11
|
+
logger.debug('Starting ShowPipeline command execution', options);
|
|
12
|
+
}
|
|
13
|
+
if (!options.reference) {
|
|
14
|
+
logger.error('Pipeline reference is required');
|
|
15
|
+
return 1;
|
|
16
|
+
}
|
|
17
|
+
const format = options.format || 'plain';
|
|
18
|
+
const spinner = Progress.spinner('Fetching pipeline details...', { format });
|
|
19
|
+
try {
|
|
20
|
+
// Initialize token first
|
|
21
|
+
this.token = await BaseCommand.getToken(options);
|
|
22
|
+
// Parse the reference to extract org/pipeline
|
|
23
|
+
const ref = parseBuildkiteReference(options.reference);
|
|
24
|
+
// Validate it's a pipeline reference
|
|
25
|
+
if (ref.type !== 'pipeline') {
|
|
26
|
+
spinner.stop();
|
|
27
|
+
logger.error('Invalid pipeline reference. Expected format: org/pipeline or URL');
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
// Fetch pipeline details
|
|
31
|
+
const pipeline = await this.client.getPipeline(ref.org, ref.pipeline);
|
|
32
|
+
spinner.stop();
|
|
33
|
+
if (!pipeline) {
|
|
34
|
+
logger.error(`Pipeline not found: ${ref.org}/${ref.pipeline}`);
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
// Fetch recent builds using pipeline-specific endpoint
|
|
38
|
+
const count = options.count || 20;
|
|
39
|
+
const builds = await this.restClient.getPipelineBuilds(ref.org, ref.pipeline, {
|
|
40
|
+
per_page: String(count),
|
|
41
|
+
});
|
|
42
|
+
// Prepare data for formatter
|
|
43
|
+
const data = {
|
|
44
|
+
org: ref.org,
|
|
45
|
+
pipeline: {
|
|
46
|
+
name: pipeline.name,
|
|
47
|
+
slug: pipeline.slug,
|
|
48
|
+
description: pipeline.description,
|
|
49
|
+
defaultBranch: pipeline.defaultBranch,
|
|
50
|
+
url: pipeline.url,
|
|
51
|
+
repository: pipeline.repository,
|
|
52
|
+
},
|
|
53
|
+
recentBuilds: (builds || []).map((build) => ({
|
|
54
|
+
number: build.number,
|
|
55
|
+
state: build.state,
|
|
56
|
+
branch: build.branch,
|
|
57
|
+
message: build.message,
|
|
58
|
+
startedAt: build.started_at,
|
|
59
|
+
finishedAt: build.finished_at,
|
|
60
|
+
})),
|
|
61
|
+
};
|
|
62
|
+
// Format and display
|
|
63
|
+
let formatter;
|
|
64
|
+
if (format === 'alfred') {
|
|
65
|
+
formatter = new AlfredPipelineDetailFormatter({});
|
|
66
|
+
}
|
|
67
|
+
else if (format === 'json') {
|
|
68
|
+
formatter = new JsonPipelineDetailFormatter({});
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
formatter = new PlainPipelineDetailFormatter({});
|
|
72
|
+
}
|
|
73
|
+
const output = formatter.format(data);
|
|
74
|
+
logger.console(output);
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
spinner.stop();
|
|
79
|
+
if (error instanceof Error) {
|
|
80
|
+
const errorOutput = formatError(error.message, {
|
|
81
|
+
suggestions: ['Check the reference format', 'Verify you have access to this resource'],
|
|
82
|
+
});
|
|
83
|
+
logger.console(errorOutput);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
logger.error('Unknown error occurred');
|
|
87
|
+
}
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=ShowPipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShowPipeline.js","sourceRoot":"/","sources":["commands/ShowPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAsB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,M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,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACxB,SAAS,GAAG,IAAI,6BAA6B,CAAC,EAAE,CAAC,CAAC;YACpD,CAAC;iBAAM,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC7B,SAAS,GAAG,IAAI,2BAA2B,CAAC,EAAE,CAAC,CAAC;YAClD,CAAC;iBAAM,CAAC;gBACN,SAAS,GAAG,IAAI,4BAA4B,CAAC,EAAE,CAAC,CAAC;YACnD,CAAC;YAED,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACtC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAEvB,OAAO,CAAC,CAAC;QACX,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE;oBAC7C,WAAW,EAAE,CAAC,4BAA4B,EAAE,yCAAyC,CAAC;iBACvF,CAAC,CAAC;gBACH,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC","sourcesContent":["import { BaseCommand, BaseCommandOptions } from './BaseCommand.js';\nimport { logger } from '../services/logger.js';\nimport { parseBuildkiteReference } from '../utils/parseBuildkiteReference.js';\nimport { PlainPipelineDetailFormatter, JsonPipelineDetailFormatter, AlfredPipelineDetailFormatter } from '../formatters/pipeline-detail/index.js';\nimport type { PipelineDetailData } from '../formatters/pipeline-detail/Formatter.js';\nimport { formatError } from '../ui/theme.js';\nimport { Progress } from '../ui/progress.js';\n\nexport interface ShowPipelineOptions extends BaseCommandOptions {\n reference: string;\n count?: number;\n}\n\nexport class ShowPipeline extends BaseCommand {\n static requiresToken = true;\n\n async execute(options: ShowPipelineOptions): Promise<number> {\n if (options.debug) {\n logger.debug('Starting ShowPipeline command execution', options);\n }\n\n if (!options.reference) {\n logger.error('Pipeline reference is required');\n return 1;\n }\n\n const format = options.format || 'plain';\n const spinner = Progress.spinner('Fetching pipeline details...', { format });\n\n try {\n // Initialize token first\n this.token = await BaseCommand.getToken(options);\n\n // Parse the reference to extract org/pipeline\n const ref = parseBuildkiteReference(options.reference);\n\n // Validate it's a pipeline reference\n if (ref.type !== 'pipeline') {\n spinner.stop();\n logger.error('Invalid pipeline reference. Expected format: org/pipeline or URL');\n return 1;\n }\n\n // Fetch pipeline details\n const pipeline = await this.client.getPipeline(ref.org, ref.pipeline);\n spinner.stop();\n\n if (!pipeline) {\n logger.error(`Pipeline not found: ${ref.org}/${ref.pipeline}`);\n return 1;\n }\n\n // Fetch recent builds using pipeline-specific endpoint\n const count = options.count || 20;\n const builds = await this.restClient.getPipelineBuilds(ref.org, ref.pipeline, {\n per_page: String(count),\n });\n\n // Prepare data for formatter\n const data: PipelineDetailData = {\n org: ref.org,\n pipeline: {\n name: pipeline.name,\n slug: pipeline.slug,\n description: pipeline.description,\n defaultBranch: pipeline.defaultBranch,\n url: pipeline.url,\n repository: pipeline.repository,\n },\n recentBuilds: (builds || []).map((build: any) => ({\n number: build.number,\n state: build.state,\n branch: build.branch,\n message: build.message,\n startedAt: build.started_at,\n finishedAt: build.finished_at,\n })),\n };\n\n // Format and display\n let formatter;\n\n if (format === 'alfred') {\n formatter = new AlfredPipelineDetailFormatter({});\n } else if (format === 'json') {\n formatter = new JsonPipelineDetailFormatter({});\n } else {\n formatter = new PlainPipelineDetailFormatter({});\n }\n\n const output = formatter.format(data);\n logger.console(output);\n\n return 0;\n } catch (error) {\n spinner.stop();\n if (error instanceof Error) {\n const errorOutput = formatError(error.message, {\n suggestions: ['Check the reference format', 'Verify you have access to this resource'],\n });\n logger.console(errorOutput);\n } else {\n logger.error('Unknown error occurred');\n }\n return 1;\n }\n }\n}\n"]}
|
|
@@ -2,11 +2,9 @@ import { BaseCommand } from './BaseCommand.js';
|
|
|
2
2
|
import { parseBuildkiteReference } from '../utils/parseBuildkiteReference.js';
|
|
3
3
|
import { logger } from '../services/logger.js';
|
|
4
4
|
import { ShowBuild } from './ShowBuild.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Progress } from '../ui/progress.js';
|
|
9
|
-
import * as fs from 'fs/promises';
|
|
5
|
+
import { ShowPipeline } from './ShowPipeline.js';
|
|
6
|
+
import { ShowLogs } from './ShowLogs.js';
|
|
7
|
+
import { formatError } from '../ui/theme.js';
|
|
10
8
|
export class SmartShow extends BaseCommand {
|
|
11
9
|
static requiresToken = true;
|
|
12
10
|
async execute(options) {
|
|
@@ -50,70 +48,12 @@ export class SmartShow extends BaseCommand {
|
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
async showPipeline(ref, options) {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const pipeline = await this.client.getPipeline(ref.org, ref.pipeline);
|
|
60
|
-
spinner.stop();
|
|
61
|
-
if (!pipeline) {
|
|
62
|
-
logger.error(`Pipeline not found: ${ref.org}/${ref.pipeline}`);
|
|
63
|
-
return 1;
|
|
64
|
-
}
|
|
65
|
-
// Fetch recent builds using pipeline-specific endpoint
|
|
66
|
-
const builds = await this.restClient.getPipelineBuilds(ref.org, ref.pipeline, {
|
|
67
|
-
per_page: '20',
|
|
68
|
-
});
|
|
69
|
-
// Prepare data for formatter
|
|
70
|
-
const data = {
|
|
71
|
-
org: ref.org,
|
|
72
|
-
pipeline: {
|
|
73
|
-
name: pipeline.name,
|
|
74
|
-
slug: pipeline.slug,
|
|
75
|
-
description: pipeline.description,
|
|
76
|
-
defaultBranch: pipeline.defaultBranch,
|
|
77
|
-
url: pipeline.url,
|
|
78
|
-
repository: pipeline.repository,
|
|
79
|
-
},
|
|
80
|
-
recentBuilds: (builds || []).map((build) => ({
|
|
81
|
-
number: build.number,
|
|
82
|
-
state: build.state,
|
|
83
|
-
branch: build.branch,
|
|
84
|
-
message: build.message,
|
|
85
|
-
startedAt: build.started_at,
|
|
86
|
-
finishedAt: build.finished_at,
|
|
87
|
-
})),
|
|
88
|
-
};
|
|
89
|
-
// Format and display
|
|
90
|
-
let formatter;
|
|
91
|
-
if (format === 'alfred') {
|
|
92
|
-
formatter = new AlfredPipelineDetailFormatter({});
|
|
93
|
-
}
|
|
94
|
-
else if (format === 'json') {
|
|
95
|
-
formatter = new JsonPipelineDetailFormatter({});
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
formatter = new PlainPipelineDetailFormatter({});
|
|
99
|
-
}
|
|
100
|
-
const output = formatter.format(data);
|
|
101
|
-
logger.console(output);
|
|
102
|
-
return 0;
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
spinner.stop();
|
|
106
|
-
if (error instanceof Error) {
|
|
107
|
-
const errorOutput = formatError(error.message, {
|
|
108
|
-
suggestions: ['Check the reference format', 'Verify you have access to this resource'],
|
|
109
|
-
});
|
|
110
|
-
logger.console(errorOutput);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
logger.error('Unknown error occurred');
|
|
114
|
-
}
|
|
115
|
-
return 1;
|
|
116
|
-
}
|
|
51
|
+
const pipelineCommand = new ShowPipeline();
|
|
52
|
+
return await pipelineCommand.execute({
|
|
53
|
+
...options,
|
|
54
|
+
reference: `${ref.org}/${ref.pipeline}`,
|
|
55
|
+
count: 20, // Default for smart references
|
|
56
|
+
});
|
|
117
57
|
}
|
|
118
58
|
async showBuild(ref, options) {
|
|
119
59
|
// Route to ShowBuild with enhanced defaults (--jobs --failed)
|
|
@@ -127,124 +67,12 @@ export class SmartShow extends BaseCommand {
|
|
|
127
67
|
return await buildCommand.execute(buildOptions);
|
|
128
68
|
}
|
|
129
69
|
async showBuildWithStep(ref, options) {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const build = await this.restClient.getBuild(ref.org, ref.pipeline, ref.buildNumber);
|
|
137
|
-
const jobs = build.jobs || [];
|
|
138
|
-
if (!jobs || jobs.length === 0) {
|
|
139
|
-
spinner.stop();
|
|
140
|
-
logger.error(`Build not found: ${ref.org}/${ref.pipeline}/${ref.buildNumber}`);
|
|
141
|
-
return 1;
|
|
142
|
-
}
|
|
143
|
-
// Find job by step ID (sid from URL) - step.id is different from job.id
|
|
144
|
-
if (options.debug) {
|
|
145
|
-
logger.debug(`Found ${jobs.length} jobs in build`);
|
|
146
|
-
logger.debug(`Looking for step ID: ${ref.stepId}`);
|
|
147
|
-
// Log first few jobs for debugging
|
|
148
|
-
jobs.slice(0, 3).forEach((j) => {
|
|
149
|
-
logger.debug(` Job: id=${j.id}, step.id=${j.step?.id}, name=${j.name}`);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
const job = jobs.find((j) => j.step?.id === ref.stepId);
|
|
153
|
-
if (!job) {
|
|
154
|
-
spinner.stop();
|
|
155
|
-
logger.error(`Step not found in build #${ref.buildNumber}: ${ref.stepId}`);
|
|
156
|
-
return 1;
|
|
157
|
-
}
|
|
158
|
-
// Use job.id (job UUID) for log fetching, not ref.stepId
|
|
159
|
-
const logData = await this.restClient.getJobLog(ref.org, ref.pipeline, ref.buildNumber, job.id);
|
|
160
|
-
spinner.stop();
|
|
161
|
-
// Parse log content
|
|
162
|
-
const logLines = logData.content.split('\n');
|
|
163
|
-
const totalLines = logLines.length;
|
|
164
|
-
// Determine how many lines to display
|
|
165
|
-
const linesToShow = options.full ? totalLines : (options.lines || 50);
|
|
166
|
-
const startLine = Math.max(0, totalLines - linesToShow);
|
|
167
|
-
const displayedLines = logLines.slice(startLine);
|
|
168
|
-
// Save to file if requested
|
|
169
|
-
if (options.save) {
|
|
170
|
-
await fs.writeFile(options.save, logData.content);
|
|
171
|
-
logger.console(SEMANTIC_COLORS.success(`✓ Log saved to ${options.save} (${this.formatSize(logData.size)}, ${totalLines} lines)`));
|
|
172
|
-
}
|
|
173
|
-
// Prepare data for formatter using REST API fields from build object
|
|
174
|
-
const data = {
|
|
175
|
-
build: {
|
|
176
|
-
org: ref.org,
|
|
177
|
-
pipeline: ref.pipeline,
|
|
178
|
-
number: ref.buildNumber,
|
|
179
|
-
state: build.state || 'unknown',
|
|
180
|
-
startedAt: build.started_at,
|
|
181
|
-
finishedAt: build.finished_at,
|
|
182
|
-
url: build.web_url,
|
|
183
|
-
},
|
|
184
|
-
step: {
|
|
185
|
-
id: job.id,
|
|
186
|
-
label: job.name,
|
|
187
|
-
state: job.state,
|
|
188
|
-
exitStatus: job.exit_status,
|
|
189
|
-
startedAt: job.started_at,
|
|
190
|
-
finishedAt: job.finished_at,
|
|
191
|
-
},
|
|
192
|
-
logs: {
|
|
193
|
-
content: displayedLines.join('\n'),
|
|
194
|
-
size: logData.size,
|
|
195
|
-
totalLines,
|
|
196
|
-
displayedLines: displayedLines.length,
|
|
197
|
-
startLine,
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
// Format and display (unless only saving)
|
|
201
|
-
if (!options.save || options.format) {
|
|
202
|
-
let formatter;
|
|
203
|
-
if (format === 'alfred') {
|
|
204
|
-
formatter = new AlfredStepLogsFormatter({ full: options.full, lines: options.lines });
|
|
205
|
-
}
|
|
206
|
-
else if (format === 'json') {
|
|
207
|
-
formatter = new JsonStepLogsFormatter({ full: options.full, lines: options.lines });
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
formatter = new PlainStepLogsFormatter({ full: options.full, lines: options.lines });
|
|
211
|
-
}
|
|
212
|
-
const output = formatter.format(data);
|
|
213
|
-
logger.console(output);
|
|
214
|
-
}
|
|
215
|
-
return 0;
|
|
216
|
-
}
|
|
217
|
-
catch (error) {
|
|
218
|
-
spinner.stop();
|
|
219
|
-
if (error instanceof Error) {
|
|
220
|
-
if (error.message.includes('401') || error.message.includes('403')) {
|
|
221
|
-
const errorOutput = formatError('Permission denied', {
|
|
222
|
-
suggestions: [
|
|
223
|
-
'Your API token needs \'read_build_logs\' scope to view logs',
|
|
224
|
-
'Update your token at: https://buildkite.com/user/api-access-tokens',
|
|
225
|
-
],
|
|
226
|
-
});
|
|
227
|
-
logger.console(errorOutput);
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
const errorOutput = formatError(error.message, {
|
|
231
|
-
suggestions: ['Check the reference format', 'Verify you have access to this resource'],
|
|
232
|
-
});
|
|
233
|
-
logger.console(errorOutput);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
logger.error('Unknown error occurred');
|
|
238
|
-
}
|
|
239
|
-
return 1;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
formatSize(bytes) {
|
|
243
|
-
if (bytes < 1024)
|
|
244
|
-
return `${bytes} B`;
|
|
245
|
-
if (bytes < 1024 * 1024)
|
|
246
|
-
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
247
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
70
|
+
const logsCommand = new ShowLogs();
|
|
71
|
+
return await logsCommand.execute({
|
|
72
|
+
...options,
|
|
73
|
+
buildRef: `${ref.org}/${ref.pipeline}/${ref.buildNumber}`,
|
|
74
|
+
stepId: ref.stepId,
|
|
75
|
+
});
|
|
248
76
|
}
|
|
249
77
|
}
|
|
250
78
|
//# sourceMappingURL=SmartShow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmartShow.js","sourceRoot":"/","sources":["commands/SmartShow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAsB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAsB,MAAM,qCAAqC,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,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C,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QAClE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IACpD,CAAC","sourcesContent":["import { BaseCommand, BaseCommandOptions } from './BaseCommand.js';\nimport { parseBuildkiteReference, BuildkiteReference } from '../utils/parseBuildkiteReference.js';\nimport { logger } from '../services/logger.js';\nimport { ShowBuild } from './ShowBuild.js';\nimport { PlainPipelineDetailFormatter, JsonPipelineDetailFormatter, AlfredPipelineDetailFormatter } from '../formatters/pipeline-detail/index.js';\nimport type { PipelineDetailData } from '../formatters/pipeline-detail/Formatter.js';\nimport { PlainStepLogsFormatter, JsonStepLogsFormatter, AlfredStepLogsFormatter } from '../formatters/step-logs/index.js';\nimport type { StepLogsData } from '../formatters/step-logs/Formatter.js';\nimport { SEMANTIC_COLORS, formatError } from '../ui/theme.js';\nimport { Progress } from '../ui/progress.js';\nimport * as fs from 'fs/promises';\n\nexport interface SmartShowOptions extends BaseCommandOptions {\n reference: string;\n // Log display options\n full?: boolean;\n lines?: number;\n save?: string;\n}\n\nexport class SmartShow extends BaseCommand {\n static requiresToken = true;\n\n async execute(options: SmartShowOptions): Promise<number> {\n if (options.debug) {\n logger.debug('Starting SmartShow command execution', options);\n }\n\n if (!options.reference) {\n logger.error('Reference is required');\n return 1;\n }\n\n try {\n // Parse the reference\n const ref = parseBuildkiteReference(options.reference);\n \n if (options.debug) {\n logger.debug('Parsed reference:', ref);\n }\n\n // Route based on reference type\n switch (ref.type) {\n case 'pipeline':\n return await this.showPipeline(ref, options);\n case 'build':\n return await this.showBuild(ref, options);\n case 'build-with-step':\n return await this.showBuildWithStep(ref, options);\n default:\n logger.error('Unknown reference type');\n return 1;\n }\n } catch (error) {\n if (error instanceof Error) {\n const errorOutput = formatError(error.message, {\n suggestions: ['Check the reference format', 'Verify you have access to this resource'],\n });\n logger.console(errorOutput);\n } else {\n logger.error('Unknown error occurred');\n }\n return 1;\n }\n }\n\n private async showPipeline(\n ref: Extract<BuildkiteReference, { type: 'pipeline' }>,\n options: SmartShowOptions\n ): Promise<number> {\n const format = options.format || 'plain';\n const spinner = Progress.spinner('Fetching pipeline details...', { format });\n\n try {\n // Initialize token first\n this.token = await BaseCommand.getToken(options);\n \n // Fetch pipeline details\n const pipeline = await this.client.getPipeline(ref.org, ref.pipeline);\n spinner.stop();\n \n if (!pipeline) {\n logger.error(`Pipeline not found: ${ref.org}/${ref.pipeline}`);\n return 1;\n }\n\n // Fetch recent builds using pipeline-specific endpoint\n const builds = await this.restClient.getPipelineBuilds(ref.org, ref.pipeline, {\n per_page: '20',\n });\n\n // Prepare data for formatter\n const data: PipelineDetailData = {\n org: ref.org,\n pipeline: {\n name: pipeline.name,\n slug: pipeline.slug,\n description: pipeline.description,\n defaultBranch: pipeline.defaultBranch,\n url: pipeline.url,\n repository: pipeline.repository,\n },\n recentBuilds: (builds || []).map((build: any) => ({\n number: build.number,\n state: build.state,\n branch: build.branch,\n message: build.message,\n startedAt: build.started_at,\n finishedAt: build.finished_at,\n })),\n };\n\n // Format and display\n let formatter;\n \n if (format === 'alfred') {\n formatter = new AlfredPipelineDetailFormatter({});\n } else if (format === 'json') {\n formatter = new JsonPipelineDetailFormatter({});\n } else {\n formatter = new PlainPipelineDetailFormatter({});\n }\n\n const output = formatter.format(data);\n logger.console(output);\n\n return 0;\n } catch (error) {\n spinner.stop();\n if (error instanceof Error) {\n const errorOutput = formatError(error.message, {\n suggestions: ['Check the reference format', 'Verify you have access to this resource'],\n });\n logger.console(errorOutput);\n } else {\n logger.error('Unknown error occurred');\n }\n return 1;\n }\n }\n\n private async showBuild(\n ref: Extract<BuildkiteReference, { type: 'build' }>,\n options: SmartShowOptions\n ): Promise<number> {\n // Route to ShowBuild with enhanced defaults (--jobs --failed)\n const buildCommand = new ShowBuild(options);\n \n const buildOptions = {\n ...options,\n buildArg: `${ref.org}/${ref.pipeline}/${ref.buildNumber}`,\n jobs: true,\n failed: true,\n };\n\n return await buildCommand.execute(buildOptions);\n }\n\n private async showBuildWithStep(\n ref: Extract<BuildkiteReference, { type: 'build-with-step' }>,\n options: SmartShowOptions\n ): Promise<number> {\n const format = options.format || 'plain';\n const spinner = Progress.spinner('Fetching step logs...', { format });\n\n try {\n // Initialize token first\n this.token = await BaseCommand.getToken(options);\n\n // Use REST API to get build with jobs (step.id field needed for matching)\n const build = await this.restClient.getBuild(ref.org, ref.pipeline, ref.buildNumber);\n const jobs = build.jobs || [];\n \n if (!jobs || jobs.length === 0) {\n spinner.stop();\n logger.error(`Build not found: ${ref.org}/${ref.pipeline}/${ref.buildNumber}`);\n return 1;\n }\n\n // Find job by step ID (sid from URL) - step.id is different from job.id\n if (options.debug) {\n logger.debug(`Found ${jobs.length} jobs in build`);\n logger.debug(`Looking for step ID: ${ref.stepId}`);\n // Log first few jobs for debugging\n jobs.slice(0, 3).forEach((j: any) => {\n logger.debug(` Job: id=${j.id}, step.id=${j.step?.id}, name=${j.name}`);\n });\n }\n const job = jobs.find((j: any) => j.step?.id === ref.stepId);\n \n if (!job) {\n spinner.stop();\n logger.error(`Step not found in build #${ref.buildNumber}: ${ref.stepId}`);\n return 1;\n }\n\n // Use job.id (job UUID) for log fetching, not ref.stepId\n const logData = await this.restClient.getJobLog(ref.org, ref.pipeline, ref.buildNumber, job.id);\n spinner.stop();\n\n // Parse log content\n const logLines = logData.content.split('\\n');\n const totalLines = logLines.length;\n \n // Determine how many lines to display\n const linesToShow = options.full ? totalLines : (options.lines || 50);\n const startLine = Math.max(0, totalLines - linesToShow);\n const displayedLines = logLines.slice(startLine);\n\n // Save to file if requested\n if (options.save) {\n await fs.writeFile(options.save, logData.content);\n logger.console(SEMANTIC_COLORS.success(`✓ Log saved to ${options.save} (${this.formatSize(logData.size)}, ${totalLines} lines)`));\n }\n\n // Prepare data for formatter using REST API fields from build object\n const data: StepLogsData = {\n build: {\n org: ref.org,\n pipeline: ref.pipeline,\n number: ref.buildNumber,\n state: build.state || 'unknown',\n startedAt: build.started_at,\n finishedAt: build.finished_at,\n url: build.web_url,\n },\n step: {\n id: job.id,\n label: job.name,\n state: job.state,\n exitStatus: job.exit_status,\n startedAt: job.started_at,\n finishedAt: job.finished_at,\n },\n logs: {\n content: displayedLines.join('\\n'),\n size: logData.size,\n totalLines,\n displayedLines: displayedLines.length,\n startLine,\n },\n };\n\n // Format and display (unless only saving)\n if (!options.save || options.format) {\n let formatter;\n \n if (format === 'alfred') {\n formatter = new AlfredStepLogsFormatter({ full: options.full, lines: options.lines });\n } else if (format === 'json') {\n formatter = new JsonStepLogsFormatter({ full: options.full, lines: options.lines });\n } else {\n formatter = new PlainStepLogsFormatter({ full: options.full, lines: options.lines });\n }\n\n const output = formatter.format(data);\n logger.console(output);\n }\n\n return 0;\n } catch (error) {\n spinner.stop();\n if (error instanceof Error) {\n if (error.message.includes('401') || error.message.includes('403')) {\n const errorOutput = formatError('Permission denied', {\n suggestions: [\n 'Your API token needs \\'read_build_logs\\' scope to view logs',\n 'Update your token at: https://buildkite.com/user/api-access-tokens',\n ],\n });\n logger.console(errorOutput);\n } else {\n const errorOutput = formatError(error.message, {\n suggestions: ['Check the reference format', 'Verify you have access to this resource'],\n });\n logger.console(errorOutput);\n }\n } else {\n logger.error('Unknown error occurred');\n }\n return 1;\n }\n }\n\n private formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SmartShow.js","sourceRoot":"/","sources":["commands/SmartShow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAsB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAsB,MAAM,qCAAqC,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE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G,OAAO;YACV,QAAQ,EAAE,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,WAAW,EAAE;YACzD,MAAM,EAAE,GAAG,CAAC,MAAM;SACnB,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { BaseCommand, BaseCommandOptions } from './BaseCommand.js';\nimport { parseBuildkiteReference, BuildkiteReference } from '../utils/parseBuildkiteReference.js';\nimport { logger } from '../services/logger.js';\nimport { ShowBuild } from './ShowBuild.js';\nimport { ShowPipeline } from './ShowPipeline.js';\nimport { ShowLogs } from './ShowLogs.js';\nimport { formatError } from '../ui/theme.js';\n\nexport interface SmartShowOptions extends BaseCommandOptions {\n reference: string;\n // Log display options\n full?: boolean;\n lines?: number;\n save?: string;\n}\n\nexport class SmartShow extends BaseCommand {\n static requiresToken = true;\n\n async execute(options: SmartShowOptions): Promise<number> {\n if (options.debug) {\n logger.debug('Starting SmartShow command execution', options);\n }\n\n if (!options.reference) {\n logger.error('Reference is required');\n return 1;\n }\n\n try {\n // Parse the reference\n const ref = parseBuildkiteReference(options.reference);\n \n if (options.debug) {\n logger.debug('Parsed reference:', ref);\n }\n\n // Route based on reference type\n switch (ref.type) {\n case 'pipeline':\n return await this.showPipeline(ref, options);\n case 'build':\n return await this.showBuild(ref, options);\n case 'build-with-step':\n return await this.showBuildWithStep(ref, options);\n default:\n logger.error('Unknown reference type');\n return 1;\n }\n } catch (error) {\n if (error instanceof Error) {\n const errorOutput = formatError(error.message, {\n suggestions: ['Check the reference format', 'Verify you have access to this resource'],\n });\n logger.console(errorOutput);\n } else {\n logger.error('Unknown error occurred');\n }\n return 1;\n }\n }\n\n private async showPipeline(\n ref: Extract<BuildkiteReference, { type: 'pipeline' }>,\n options: SmartShowOptions\n ): Promise<number> {\n const pipelineCommand = new ShowPipeline();\n return await pipelineCommand.execute({\n ...options,\n reference: `${ref.org}/${ref.pipeline}`,\n count: 20, // Default for smart references\n });\n }\n\n private async showBuild(\n ref: Extract<BuildkiteReference, { type: 'build' }>,\n options: SmartShowOptions\n ): Promise<number> {\n // Route to ShowBuild with enhanced defaults (--jobs --failed)\n const buildCommand = new ShowBuild(options);\n \n const buildOptions = {\n ...options,\n buildArg: `${ref.org}/${ref.pipeline}/${ref.buildNumber}`,\n jobs: true,\n failed: true,\n };\n\n return await buildCommand.execute(buildOptions);\n }\n\n private async showBuildWithStep(\n ref: Extract<BuildkiteReference, { type: 'build-with-step' }>,\n options: SmartShowOptions\n ): Promise<number> {\n const logsCommand = new ShowLogs();\n return await logsCommand.execute({\n ...options,\n buildRef: `${ref.org}/${ref.pipeline}/${ref.buildNumber}`,\n stepId: ref.stepId,\n });\n }\n}\n"]}
|
package/dist/commands/index.js
CHANGED
|
@@ -7,5 +7,7 @@ export * from './ManageToken.js';
|
|
|
7
7
|
export * from './ListAnnotations.js';
|
|
8
8
|
export * from './GenerateCompletions.js';
|
|
9
9
|
export * from './ShowBuild.js';
|
|
10
|
+
export * from './ShowPipeline.js';
|
|
11
|
+
export * from './ShowLogs.js';
|
|
10
12
|
export * from './SmartShow.js';
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './BaseCommand.js';\nexport * from './ShowViewer.js';\nexport * from './ListOrganizations.js';\nexport * from './ListBuilds.js';\nexport * from './ListPipelines.js';\nexport * from './ManageToken.js';\nexport * from './ListAnnotations.js';\nexport * from './GenerateCompletions.js';\nexport * from './ShowBuild.js';\nexport * from './SmartShow.js';"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './BaseCommand.js';\nexport * from './ShowViewer.js';\nexport * from './ListOrganizations.js';\nexport * from './ListBuilds.js';\nexport * from './ListPipelines.js';\nexport * from './ManageToken.js';\nexport * from './ListAnnotations.js';\nexport * from './GenerateCompletions.js';\nexport * from './ShowBuild.js';\nexport * from './ShowPipeline.js';\nexport * from './ShowLogs.js';\nexport * from './SmartShow.js';"]}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
|
-
import { BaseCommand, ShowViewer, ListOrganizations, ListBuilds, ListPipelines, ManageToken, ListAnnotations, GenerateCompletions, ShowBuild, SmartShow } from './commands/index.js';
|
|
6
|
+
import { BaseCommand, ShowViewer, ListOrganizations, ListBuilds, ListPipelines, ManageToken, ListAnnotations, GenerateCompletions, ShowBuild, ShowPipeline, ShowLogs, SmartShow } from './commands/index.js';
|
|
7
7
|
import { initializeErrorHandling } from './utils/errorUtils.js';
|
|
8
8
|
import { displayCLIError, setErrorFormat } from './utils/cli-error-handler.js';
|
|
9
9
|
import { logger, setLogLevel } from './services/logger.js';
|
|
@@ -285,6 +285,72 @@ program
|
|
|
285
285
|
.option('--full', 'Show all available information')
|
|
286
286
|
.option('--summary', 'Single-line summary only (for scripts)')
|
|
287
287
|
.action(createCommandHandler(ShowBuild));
|
|
288
|
+
// Add pipeline command
|
|
289
|
+
program
|
|
290
|
+
.command('pipeline')
|
|
291
|
+
.description('Show pipeline details and recent builds')
|
|
292
|
+
.argument('<reference>', 'Pipeline reference (org/pipeline or URL)')
|
|
293
|
+
.option('-n, --count <n>', 'Number of recent builds to show', '20')
|
|
294
|
+
.action(async function (reference) {
|
|
295
|
+
try {
|
|
296
|
+
const options = this.mergedOptions || this.opts();
|
|
297
|
+
const token = await BaseCommand.getToken(options);
|
|
298
|
+
const handler = new ShowPipeline({
|
|
299
|
+
token,
|
|
300
|
+
debug: options.debug,
|
|
301
|
+
format: options.format,
|
|
302
|
+
quiet: options.quiet,
|
|
303
|
+
tips: options.tips,
|
|
304
|
+
});
|
|
305
|
+
const exitCode = await handler.execute({
|
|
306
|
+
...options,
|
|
307
|
+
reference,
|
|
308
|
+
count: options.count ? parseInt(options.count) : 20,
|
|
309
|
+
});
|
|
310
|
+
process.exitCode = exitCode;
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
const debug = this.mergedOptions?.debug || this.opts().debug || false;
|
|
314
|
+
displayCLIError(error, debug);
|
|
315
|
+
process.exitCode = 1;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
// Add logs command
|
|
319
|
+
program
|
|
320
|
+
.command('logs')
|
|
321
|
+
.description('Show logs for a build step')
|
|
322
|
+
.argument('<build-ref>', 'Build reference (org/pipeline/build or URL)')
|
|
323
|
+
.argument('[step-id]', 'Step/job ID (or include in URL with ?sid=)')
|
|
324
|
+
.option('--full', 'Show all log lines')
|
|
325
|
+
.option('--lines <n>', 'Show last N lines', '50')
|
|
326
|
+
.option('--save <path>', 'Save logs to file')
|
|
327
|
+
.action(async function (buildRef, stepId) {
|
|
328
|
+
try {
|
|
329
|
+
const options = this.mergedOptions || this.opts();
|
|
330
|
+
const token = await BaseCommand.getToken(options);
|
|
331
|
+
const handler = new ShowLogs({
|
|
332
|
+
token,
|
|
333
|
+
debug: options.debug,
|
|
334
|
+
format: options.format,
|
|
335
|
+
quiet: options.quiet,
|
|
336
|
+
tips: options.tips,
|
|
337
|
+
});
|
|
338
|
+
const exitCode = await handler.execute({
|
|
339
|
+
...options,
|
|
340
|
+
buildRef,
|
|
341
|
+
stepId,
|
|
342
|
+
full: options.full,
|
|
343
|
+
lines: options.lines ? parseInt(options.lines) : 50,
|
|
344
|
+
save: options.save,
|
|
345
|
+
});
|
|
346
|
+
process.exitCode = exitCode;
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
const debug = this.mergedOptions?.debug || this.opts().debug || false;
|
|
350
|
+
displayCLIError(error, debug);
|
|
351
|
+
process.exitCode = 1;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
288
354
|
// Add completions command
|
|
289
355
|
program
|
|
290
356
|
.command('completions [shell]')
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EACL,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,SAAS,EACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE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AE,OAAO,CAAC,MAAM;gBACtB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;gBAC1D,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,KAAK;gBAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;YAClE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,+CAA+C;YAC/C,MAAM,CAAC,KAAK,CAAC,oBAAoB,kBAAkB,EAAE,CAAC,CAAC;YACvD,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,+BAA+B;AAC/B,OAAO,CAAC,KAAK,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport {\n BaseCommand,\n ShowViewer,\n ListOrganizations,\n ListBuilds,\n ListPipelines,\n ManageToken,\n ListAnnotations,\n GenerateCompletions,\n ShowBuild,\n SmartShow\n} from './commands/index.js';\nimport { initializeErrorHandling } from './utils/errorUtils.js';\nimport { displayCLIError, setErrorFormat } from './utils/cli-error-handler.js';\nimport { logger, setLogLevel } from './services/logger.js';\nimport { WidthAwareHelp } from './ui/help.js';\n\n// Set a global error handler for uncaught exceptions\nconst uncaughtExceptionHandler = (err: Error) => {\n // Remove any existing handlers to avoid duplicates\n const handlers = process.listeners('uncaughtException');\n handlers.forEach(listener => {\n if (listener !== uncaughtExceptionHandler) {\n process.removeListener('uncaughtException', listener);\n }\n });\n \n displayCLIError(\n err, \n process.argv.includes('--debug')\n );\n};\nprocess.on('uncaughtException', uncaughtExceptionHandler);\n\n// Set a global error handler for unhandled promise rejections\nconst unhandledRejectionHandler = (reason: unknown) => {\n // Remove any existing handlers to avoid duplicates\n const handlers = process.listeners('unhandledRejection');\n handlers.forEach(listener => {\n if (listener !== unhandledRejectionHandler) {\n process.removeListener('unhandledRejection', listener);\n }\n });\n \n displayCLIError(\n reason, \n process.argv.includes('--debug')\n );\n};\nprocess.on('unhandledRejection', unhandledRejectionHandler);\n\n// Initialize error handling after our handlers are registered\ninitializeErrorHandling();\n\nconst program = new Command();\nprogram.allowUnknownOption();\n\n// Define a generic interface for the command classes that includes the execute method\ninterface CommandWithExecute {\n execute(options: any): Promise<number>;\n}\n\n// Define a type for the constructor that includes static properties\ntype CommandConstructor = {\n new (options?: any): BaseCommand & CommandWithExecute;\n requiresToken: boolean;\n}\n\n// Extend the Command type to include our custom properties\ninterface ExtendedCommand extends Command {\n mergedOptions?: any;\n pipelineOptions?: {\n organization?: string;\n count?: number;\n filter?: string;\n };\n buildOptions?: {\n organization?: string;\n pipeline?: string;\n branch?: string;\n state?: string;\n count: number;\n page: number;\n filter?: string;\n };\n}\n\n// Handler for executing commands with proper option handling\nconst createCommandHandler = (CommandClass: CommandConstructor) => {\n return async function(this: ExtendedCommand) {\n try {\n const options = this.mergedOptions || this.opts();\n const cacheOptions = { enabled: options.cache !== false, ttl: options.cacheTtl, clear: options.clearCache };\n\n if (CommandClass.requiresToken) {\n const token = await BaseCommand.getToken(options);\n options.token = token;\n }\n \n const handler = new CommandClass({\n ...cacheOptions,\n token: options.token,\n debug: options.debug,\n format: options.format,\n quiet: options.quiet,\n tips: options.tips,\n });\n \n // Pass command-specific options if available\n const commandName = this.name();\n if (commandName === 'pipelines' && this.pipelineOptions) {\n logger.debug('Using pipeline options:', this.pipelineOptions);\n }\n else if (commandName === 'builds' && this.buildOptions) {\n logger.debug('Using build options:', this.buildOptions);\n }\n \n const exitCode = await handler.execute(options);\n // Set process.exitCode to propagate the exit code\n process.exitCode = exitCode;\n } catch (error) {\n const debug = this.mergedOptions?.debug || this.opts().debug || false;\n // No need to pass format - will use global format set in preAction hook\n displayCLIError(error, debug);\n process.exitCode = 1; // Set error exit code\n }\n };\n};\n\nfunction resolveAppVersion(): string {\n // Prefer environment-provided version (set in CI before publish)\n if (process.env.BKTIDE_VERSION && process.env.BKTIDE_VERSION.trim().length > 0) {\n return process.env.BKTIDE_VERSION.trim();\n }\n\n try {\n // Attempt to read package.json near compiled dist/index.js\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidatePaths = [\n path.resolve(__dirname, '..', 'package.json'), // when running from dist/\n path.resolve(__dirname, '..', '..', 'package.json'), // fallback\n ];\n for (const pkgPath of candidatePaths) {\n if (fs.existsSync(pkgPath)) {\n const raw = fs.readFileSync(pkgPath, 'utf-8');\n const pkg = JSON.parse(raw) as { version?: string };\n if (pkg.version) return pkg.version;\n }\n }\n } catch {\n // ignore\n }\n\n // Last resort\n return '0.0.0';\n}\n\n// Create custom help instance\nconst customHelp = new WidthAwareHelp();\n\nprogram\n .name('bktide')\n .description('Buildkite CLI tool')\n .version(resolveAppVersion())\n .configureHelp(customHelp)\n .showSuggestionAfterError()\n .option('--log-level <level>', 'Set logging level (trace, debug, info, warn, error, fatal)', 'info')\n .option('-d, --debug', 'Show debug information for errors')\n .option('--no-cache', 'Disable caching of API responses')\n .option('--cache-ttl <milliseconds>', 'Set cache time-to-live in milliseconds', parseInt)\n .option('--clear-cache', 'Clear all cached data before executing command')\n .option('-t, --token <token>', 'Buildkite API token (set BUILDKITE_API_TOKEN or BK_TOKEN env var)', process.env.BUILDKITE_API_TOKEN || process.env.BK_TOKEN)\n .option('--save-token', 'Save the token to system keychain for future use')\n .option('-f, --format <format>', 'Output format for results and errors (plain, json, alfred)', 'plain')\n .option('--color <mode>', 'Color output: auto|always|never', 'auto')\n .option('-q, --quiet', 'Suppress non-error output (plain format only)')\n .option('--tips', 'Show helpful tips and suggestions')\n .option('--no-tips', 'Hide helpful tips and suggestions')\n .option('--ascii', 'Use ASCII symbols instead of Unicode')\n .option('--full', 'Show all log lines (for step logs)')\n .option('--lines <n>', 'Show last N lines (default: 50)', '50')\n .option('--save <path>', 'Save logs to file');\n\n// Add hooks for handling options\nprogram\n .hook('preAction', (_thisCommand, actionCommand) => {\n // Cast to our extended command type\n const cmd = actionCommand as unknown as ExtendedCommand;\n \n // Merge global options with command-specific options\n const globalOpts = program.opts();\n const commandOpts = cmd.opts();\n const mergedOptions = { ...globalOpts, ...commandOpts };\n \n // Set the global error format from the command line options\n if (mergedOptions.format) {\n setErrorFormat(mergedOptions.format);\n }\n\n // Apply color mode\n if (mergedOptions.color) {\n const mode = String(mergedOptions.color).toLowerCase();\n // Respect NO_COLOR when mode is never; clear when always\n if (mode === 'never') {\n process.env.NO_COLOR = '1';\n } else if (mode === 'always') {\n // Explicitly enable color by unsetting NO_COLOR; downstream code should still TTY-check\n if (process.env.NO_COLOR) {\n delete process.env.NO_COLOR;\n }\n process.env.BKTIDE_COLOR_MODE = 'always';\n } else {\n // auto\n process.env.BKTIDE_COLOR_MODE = 'auto';\n }\n }\n \n if (mergedOptions.cacheTtl && (isNaN(mergedOptions.cacheTtl) || mergedOptions.cacheTtl <= 0)) {\n logger.error('cache-ttl must be a positive number');\n process.exitCode = 1;\n return;\n }\n \n if (mergedOptions.cache === false && mergedOptions.cacheTtl) {\n logger.warn('--no-cache and --cache-ttl used together. Cache will be disabled regardless of TTL setting.');\n }\n \n // Validate count options\n if (mergedOptions.count && (isNaN(parseInt(mergedOptions.count)) || parseInt(mergedOptions.count) <= 0)) {\n logger.error('count must be a positive number');\n process.exitCode = 1;\n return;\n }\n\n cmd.mergedOptions = mergedOptions;\n\n const commandName = cmd.name();\n\n if (commandName === 'pipelines') {\n // Create pipeline-specific options structure\n cmd.pipelineOptions = {\n organization: mergedOptions.org,\n count: mergedOptions.count ? parseInt(mergedOptions.count) : undefined,\n filter: mergedOptions.filter\n };\n \n if (mergedOptions.debug) {\n logger.debug('Pipeline options:', cmd.pipelineOptions);\n }\n }\n else if (commandName === 'builds') {\n // Create builds-specific options structure\n cmd.buildOptions = {\n organization: mergedOptions.org,\n pipeline: mergedOptions.pipeline,\n branch: mergedOptions.branch,\n state: mergedOptions.state,\n count: mergedOptions.count ? parseInt(mergedOptions.count) : 10,\n page: mergedOptions.page ? parseInt(mergedOptions.page) : 1,\n filter: mergedOptions.filter\n };\n \n if (mergedOptions.debug) {\n logger.debug('Build options:', cmd.buildOptions);\n }\n }\n else if (commandName === 'annotations') {\n // Attach the build argument to options\n cmd.mergedOptions.buildArg = cmd.args?.[0];\n \n if (mergedOptions.debug) {\n logger.debug('Annotations build arg:', cmd.mergedOptions.buildArg);\n logger.debug('Annotations context filter:', mergedOptions.context);\n }\n }\n else if (commandName === 'build') {\n // Attach the build argument to options\n cmd.mergedOptions.buildArg = cmd.args?.[0];\n \n if (mergedOptions.debug) {\n logger.debug('Build arg:', cmd.mergedOptions.buildArg);\n logger.debug('Build options:', mergedOptions);\n }\n }\n \n if (mergedOptions.debug) {\n logger.debug(`Executing command: ${commandName}`);\n logger.debug('Options:', mergedOptions);\n }\n })\n .hook('postAction', (_thisCommand, actionCommand) => {\n // Cast to our extended command type\n const cmd = actionCommand as unknown as ExtendedCommand;\n \n // Accessing the custom property\n const options = cmd.mergedOptions || {};\n if (options.debug) {\n logger.debug(`Command ${cmd.name()} completed`);\n }\n });\n\nprogram\n .command('viewer')\n .description('Show logged in user information')\n .action(createCommandHandler(ShowViewer));\n\nprogram\n .command('orgs')\n .description('List organizations')\n .action(createCommandHandler(ListOrganizations));\n\nprogram\n .command('pipelines')\n .description('List pipelines for an organization')\n .option('-o, --org <org>', 'Organization slug (optional - will search all your orgs if not specified)')\n .option('-n, --count <count>', 'Limit to specified number of pipelines per organization')\n .option('--filter <name>', 'Filter pipelines by name (case insensitive)')\n .action(createCommandHandler(ListPipelines));\n\n// Update the builds command to include REST API filtering options\nprogram\n .command('builds')\n .description('List builds for the current user')\n .option('-o, --org <org>', 'Organization slug (optional - will search all your orgs if not specified)')\n .option('-p, --pipeline <pipeline>', 'Filter by pipeline slug')\n .option('-b, --branch <branch>', 'Filter by branch name')\n .option('-s, --state <state>', 'Filter by build state (running, scheduled, passed, failing, failed, canceled, etc.)')\n .option('-n, --count <count>', 'Number of builds per page', '10')\n .option('--page <page>', 'Page number', '1')\n .option('--filter <filter>', 'Fuzzy filter builds by name or other properties')\n .action(createCommandHandler(ListBuilds));\n\n// Add token management command\nprogram\n .command('token')\n .description('Manage API tokens')\n .option('--check', 'Check if a token is stored in the system keychain')\n .option('--store', 'Store a token in the system keychain')\n .option('--reset', 'Delete the stored token from system keychain')\n .action(createCommandHandler(ManageToken));\n\n// Add annotations command\nprogram\n .command('annotations')\n .description('Show annotations for a build')\n .argument('<build>', 'Build reference (org/pipeline/number or @https://buildkite.com/org/pipeline/builds/number)')\n .option('--context <context>', 'Filter annotations by context (e.g., rspec, build-resources)')\n .action(createCommandHandler(ListAnnotations));\n\n// Add build command\nprogram\n .command('build')\n .description('Show details for a specific build')\n .argument('<build>', 'Build reference (org/pipeline/number or @https://buildkite.com/org/pipeline/builds/number)')\n .option('--jobs', 'Show job summary and details')\n .option('--failed', 'Show only failed job details (implies --jobs)')\n .option('--all-jobs', 'Show all jobs without grouping limit')\n .option('--annotations', 'Show annotation details with context')\n .option('--annotations-full', 'Show complete annotation content')\n .option('--full', 'Show all available information')\n .option('--summary', 'Single-line summary only (for scripts)')\n .action(createCommandHandler(ShowBuild));\n\n// Add completions command\nprogram\n .command('completions [shell]')\n .description('Generate shell completions')\n .action(async (shell) => {\n const handler = new GenerateCompletions();\n const exitCode = await handler.execute({ shell, quiet: program.opts().quiet, debug: program.opts().debug });\n process.exitCode = exitCode;\n });\n\nprogram\n .command('boom')\n .description('Test error handling')\n .option('--type <type>', 'Type of error to throw (basic, api, object)', 'basic')\n .option('--format <format>', 'Output format (plain, json, alfred)', 'plain')\n .action((options) => {\n switch (options.type) {\n case 'api':\n const apiError = new Error('API request failed');\n (apiError as any).response = {\n errors: [\n { message: 'Invalid token', path: ['viewer'] }\n ]\n };\n throw apiError;\n \n case 'object':\n throw {\n message: 'This is not an Error instance',\n code: 'CUSTOM_ERROR'\n };\n \n case 'basic':\n default:\n throw new Error('Boom! This is a test error');\n }\n });\n\n// Apply log level from command line options before parsing\nconst options = program.opts();\nif (options.debug) {\n // Debug mode takes precedence over log-level\n setLogLevel('debug');\n logger.debug('Debug mode enabled via --debug flag');\n} else if (options.logLevel) {\n setLogLevel(options.logLevel);\n logger.debug(`Log level set to ${options.logLevel} via --log-level option`);\n}\n\nlogger.debug({ \n pid: process.pid, \n}, 'Buildkite CLI started');\n\n// Handle unknown commands by trying to parse as Buildkite references\nprogram.on('command:*', (operands) => {\n const potentialReference = operands[0];\n \n (async () => {\n try {\n const { parseBuildkiteReference } = await import('./utils/parseBuildkiteReference.js');\n \n // Try to parse as Buildkite reference (will throw if invalid)\n parseBuildkiteReference(potentialReference);\n \n // If parsing succeeds, route to SmartShow\n const token = await BaseCommand.getToken(options);\n const smartShowCommand = new SmartShow();\n \n const smartShowOptions = {\n reference: potentialReference,\n token,\n format: options.format,\n debug: options.debug,\n full: options.full,\n lines: options.lines ? parseInt(options.lines) : undefined,\n save: options.save,\n cache: options.cache !== false,\n cacheTtl: options.cacheTtl,\n clearCache: options.clearCache,\n quiet: options.quiet,\n tips: options.tips,\n };\n \n const exitCode = await smartShowCommand.execute(smartShowOptions);\n process.exit(exitCode);\n } catch (parseError) {\n // If parsing fails, show unknown command error\n logger.error(`Unknown command: ${potentialReference}`);\n logger.error(`Run 'bktide --help' for usage information`);\n process.exit(1);\n }\n })();\n});\n\n// Parse command line arguments\nprogram.parse(); "]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EACL,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,SAAS,EACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,qDAAqD;AACrD,MAAM,wBAAwB,GAAG,CAAC,GAAU,EAAE,EAAE;IAC9C,mDAAmD;IACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IACxD,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC1B,IAAI,QAAQ,KAAK,wBAAwB,EAAE,CAAC;YAC1C,OAAO,CAAC,cAAc,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QACxD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,eAAe,CACb,GAAG,EACH,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CACjC,CAAC;AACJ,CAAC,CAAC;AACF,OAAO,CAAC,EAAE,C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,CAAC,KAAK;gBACpB,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;YAClE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,+CAA+C;YAC/C,MAAM,CAAC,KAAK,CAAC,oBAAoB,kBAAkB,EAAE,CAAC,CAAC;YACvD,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,+BAA+B;AAC/B,OAAO,CAAC,KAAK,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport {\n BaseCommand,\n ShowViewer,\n ListOrganizations,\n ListBuilds,\n ListPipelines,\n ManageToken,\n ListAnnotations,\n GenerateCompletions,\n ShowBuild,\n ShowPipeline,\n ShowLogs,\n SmartShow\n} from './commands/index.js';\nimport { initializeErrorHandling } from './utils/errorUtils.js';\nimport { displayCLIError, setErrorFormat } from './utils/cli-error-handler.js';\nimport { logger, setLogLevel } from './services/logger.js';\nimport { WidthAwareHelp } from './ui/help.js';\n\n// Set a global error handler for uncaught exceptions\nconst uncaughtExceptionHandler = (err: Error) => {\n // Remove any existing handlers to avoid duplicates\n const handlers = process.listeners('uncaughtException');\n handlers.forEach(listener => {\n if (listener !== uncaughtExceptionHandler) {\n process.removeListener('uncaughtException', listener);\n }\n });\n \n displayCLIError(\n err, \n process.argv.includes('--debug')\n );\n};\nprocess.on('uncaughtException', uncaughtExceptionHandler);\n\n// Set a global error handler for unhandled promise rejections\nconst unhandledRejectionHandler = (reason: unknown) => {\n // Remove any existing handlers to avoid duplicates\n const handlers = process.listeners('unhandledRejection');\n handlers.forEach(listener => {\n if (listener !== unhandledRejectionHandler) {\n process.removeListener('unhandledRejection', listener);\n }\n });\n \n displayCLIError(\n reason, \n process.argv.includes('--debug')\n );\n};\nprocess.on('unhandledRejection', unhandledRejectionHandler);\n\n// Initialize error handling after our handlers are registered\ninitializeErrorHandling();\n\nconst program = new Command();\nprogram.allowUnknownOption();\n\n// Define a generic interface for the command classes that includes the execute method\ninterface CommandWithExecute {\n execute(options: any): Promise<number>;\n}\n\n// Define a type for the constructor that includes static properties\ntype CommandConstructor = {\n new (options?: any): BaseCommand & CommandWithExecute;\n requiresToken: boolean;\n}\n\n// Extend the Command type to include our custom properties\ninterface ExtendedCommand extends Command {\n mergedOptions?: any;\n pipelineOptions?: {\n organization?: string;\n count?: number;\n filter?: string;\n };\n buildOptions?: {\n organization?: string;\n pipeline?: string;\n branch?: string;\n state?: string;\n count: number;\n page: number;\n filter?: string;\n };\n}\n\n// Handler for executing commands with proper option handling\nconst createCommandHandler = (CommandClass: CommandConstructor) => {\n return async function(this: ExtendedCommand) {\n try {\n const options = this.mergedOptions || this.opts();\n const cacheOptions = { enabled: options.cache !== false, ttl: options.cacheTtl, clear: options.clearCache };\n\n if (CommandClass.requiresToken) {\n const token = await BaseCommand.getToken(options);\n options.token = token;\n }\n \n const handler = new CommandClass({\n ...cacheOptions,\n token: options.token,\n debug: options.debug,\n format: options.format,\n quiet: options.quiet,\n tips: options.tips,\n });\n \n // Pass command-specific options if available\n const commandName = this.name();\n if (commandName === 'pipelines' && this.pipelineOptions) {\n logger.debug('Using pipeline options:', this.pipelineOptions);\n }\n else if (commandName === 'builds' && this.buildOptions) {\n logger.debug('Using build options:', this.buildOptions);\n }\n \n const exitCode = await handler.execute(options);\n // Set process.exitCode to propagate the exit code\n process.exitCode = exitCode;\n } catch (error) {\n const debug = this.mergedOptions?.debug || this.opts().debug || false;\n // No need to pass format - will use global format set in preAction hook\n displayCLIError(error, debug);\n process.exitCode = 1; // Set error exit code\n }\n };\n};\n\nfunction resolveAppVersion(): string {\n // Prefer environment-provided version (set in CI before publish)\n if (process.env.BKTIDE_VERSION && process.env.BKTIDE_VERSION.trim().length > 0) {\n return process.env.BKTIDE_VERSION.trim();\n }\n\n try {\n // Attempt to read package.json near compiled dist/index.js\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidatePaths = [\n path.resolve(__dirname, '..', 'package.json'), // when running from dist/\n path.resolve(__dirname, '..', '..', 'package.json'), // fallback\n ];\n for (const pkgPath of candidatePaths) {\n if (fs.existsSync(pkgPath)) {\n const raw = fs.readFileSync(pkgPath, 'utf-8');\n const pkg = JSON.parse(raw) as { version?: string };\n if (pkg.version) return pkg.version;\n }\n }\n } catch {\n // ignore\n }\n\n // Last resort\n return '0.0.0';\n}\n\n// Create custom help instance\nconst customHelp = new WidthAwareHelp();\n\nprogram\n .name('bktide')\n .description('Buildkite CLI tool')\n .version(resolveAppVersion())\n .configureHelp(customHelp)\n .showSuggestionAfterError()\n .option('--log-level <level>', 'Set logging level (trace, debug, info, warn, error, fatal)', 'info')\n .option('-d, --debug', 'Show debug information for errors')\n .option('--no-cache', 'Disable caching of API responses')\n .option('--cache-ttl <milliseconds>', 'Set cache time-to-live in milliseconds', parseInt)\n .option('--clear-cache', 'Clear all cached data before executing command')\n .option('-t, --token <token>', 'Buildkite API token (set BUILDKITE_API_TOKEN or BK_TOKEN env var)', process.env.BUILDKITE_API_TOKEN || process.env.BK_TOKEN)\n .option('--save-token', 'Save the token to system keychain for future use')\n .option('-f, --format <format>', 'Output format for results and errors (plain, json, alfred)', 'plain')\n .option('--color <mode>', 'Color output: auto|always|never', 'auto')\n .option('-q, --quiet', 'Suppress non-error output (plain format only)')\n .option('--tips', 'Show helpful tips and suggestions')\n .option('--no-tips', 'Hide helpful tips and suggestions')\n .option('--ascii', 'Use ASCII symbols instead of Unicode')\n .option('--full', 'Show all log lines (for step logs)')\n .option('--lines <n>', 'Show last N lines (default: 50)', '50')\n .option('--save <path>', 'Save logs to file');\n\n// Add hooks for handling options\nprogram\n .hook('preAction', (_thisCommand, actionCommand) => {\n // Cast to our extended command type\n const cmd = actionCommand as unknown as ExtendedCommand;\n \n // Merge global options with command-specific options\n const globalOpts = program.opts();\n const commandOpts = cmd.opts();\n const mergedOptions = { ...globalOpts, ...commandOpts };\n \n // Set the global error format from the command line options\n if (mergedOptions.format) {\n setErrorFormat(mergedOptions.format);\n }\n\n // Apply color mode\n if (mergedOptions.color) {\n const mode = String(mergedOptions.color).toLowerCase();\n // Respect NO_COLOR when mode is never; clear when always\n if (mode === 'never') {\n process.env.NO_COLOR = '1';\n } else if (mode === 'always') {\n // Explicitly enable color by unsetting NO_COLOR; downstream code should still TTY-check\n if (process.env.NO_COLOR) {\n delete process.env.NO_COLOR;\n }\n process.env.BKTIDE_COLOR_MODE = 'always';\n } else {\n // auto\n process.env.BKTIDE_COLOR_MODE = 'auto';\n }\n }\n \n if (mergedOptions.cacheTtl && (isNaN(mergedOptions.cacheTtl) || mergedOptions.cacheTtl <= 0)) {\n logger.error('cache-ttl must be a positive number');\n process.exitCode = 1;\n return;\n }\n \n if (mergedOptions.cache === false && mergedOptions.cacheTtl) {\n logger.warn('--no-cache and --cache-ttl used together. Cache will be disabled regardless of TTL setting.');\n }\n \n // Validate count options\n if (mergedOptions.count && (isNaN(parseInt(mergedOptions.count)) || parseInt(mergedOptions.count) <= 0)) {\n logger.error('count must be a positive number');\n process.exitCode = 1;\n return;\n }\n\n cmd.mergedOptions = mergedOptions;\n\n const commandName = cmd.name();\n\n if (commandName === 'pipelines') {\n // Create pipeline-specific options structure\n cmd.pipelineOptions = {\n organization: mergedOptions.org,\n count: mergedOptions.count ? parseInt(mergedOptions.count) : undefined,\n filter: mergedOptions.filter\n };\n \n if (mergedOptions.debug) {\n logger.debug('Pipeline options:', cmd.pipelineOptions);\n }\n }\n else if (commandName === 'builds') {\n // Create builds-specific options structure\n cmd.buildOptions = {\n organization: mergedOptions.org,\n pipeline: mergedOptions.pipeline,\n branch: mergedOptions.branch,\n state: mergedOptions.state,\n count: mergedOptions.count ? parseInt(mergedOptions.count) : 10,\n page: mergedOptions.page ? parseInt(mergedOptions.page) : 1,\n filter: mergedOptions.filter\n };\n \n if (mergedOptions.debug) {\n logger.debug('Build options:', cmd.buildOptions);\n }\n }\n else if (commandName === 'annotations') {\n // Attach the build argument to options\n cmd.mergedOptions.buildArg = cmd.args?.[0];\n \n if (mergedOptions.debug) {\n logger.debug('Annotations build arg:', cmd.mergedOptions.buildArg);\n logger.debug('Annotations context filter:', mergedOptions.context);\n }\n }\n else if (commandName === 'build') {\n // Attach the build argument to options\n cmd.mergedOptions.buildArg = cmd.args?.[0];\n \n if (mergedOptions.debug) {\n logger.debug('Build arg:', cmd.mergedOptions.buildArg);\n logger.debug('Build options:', mergedOptions);\n }\n }\n \n if (mergedOptions.debug) {\n logger.debug(`Executing command: ${commandName}`);\n logger.debug('Options:', mergedOptions);\n }\n })\n .hook('postAction', (_thisCommand, actionCommand) => {\n // Cast to our extended command type\n const cmd = actionCommand as unknown as ExtendedCommand;\n \n // Accessing the custom property\n const options = cmd.mergedOptions || {};\n if (options.debug) {\n logger.debug(`Command ${cmd.name()} completed`);\n }\n });\n\nprogram\n .command('viewer')\n .description('Show logged in user information')\n .action(createCommandHandler(ShowViewer));\n\nprogram\n .command('orgs')\n .description('List organizations')\n .action(createCommandHandler(ListOrganizations));\n\nprogram\n .command('pipelines')\n .description('List pipelines for an organization')\n .option('-o, --org <org>', 'Organization slug (optional - will search all your orgs if not specified)')\n .option('-n, --count <count>', 'Limit to specified number of pipelines per organization')\n .option('--filter <name>', 'Filter pipelines by name (case insensitive)')\n .action(createCommandHandler(ListPipelines));\n\n// Update the builds command to include REST API filtering options\nprogram\n .command('builds')\n .description('List builds for the current user')\n .option('-o, --org <org>', 'Organization slug (optional - will search all your orgs if not specified)')\n .option('-p, --pipeline <pipeline>', 'Filter by pipeline slug')\n .option('-b, --branch <branch>', 'Filter by branch name')\n .option('-s, --state <state>', 'Filter by build state (running, scheduled, passed, failing, failed, canceled, etc.)')\n .option('-n, --count <count>', 'Number of builds per page', '10')\n .option('--page <page>', 'Page number', '1')\n .option('--filter <filter>', 'Fuzzy filter builds by name or other properties')\n .action(createCommandHandler(ListBuilds));\n\n// Add token management command\nprogram\n .command('token')\n .description('Manage API tokens')\n .option('--check', 'Check if a token is stored in the system keychain')\n .option('--store', 'Store a token in the system keychain')\n .option('--reset', 'Delete the stored token from system keychain')\n .action(createCommandHandler(ManageToken));\n\n// Add annotations command\nprogram\n .command('annotations')\n .description('Show annotations for a build')\n .argument('<build>', 'Build reference (org/pipeline/number or @https://buildkite.com/org/pipeline/builds/number)')\n .option('--context <context>', 'Filter annotations by context (e.g., rspec, build-resources)')\n .action(createCommandHandler(ListAnnotations));\n\n// Add build command\nprogram\n .command('build')\n .description('Show details for a specific build')\n .argument('<build>', 'Build reference (org/pipeline/number or @https://buildkite.com/org/pipeline/builds/number)')\n .option('--jobs', 'Show job summary and details')\n .option('--failed', 'Show only failed job details (implies --jobs)')\n .option('--all-jobs', 'Show all jobs without grouping limit')\n .option('--annotations', 'Show annotation details with context')\n .option('--annotations-full', 'Show complete annotation content')\n .option('--full', 'Show all available information')\n .option('--summary', 'Single-line summary only (for scripts)')\n .action(createCommandHandler(ShowBuild));\n\n// Add pipeline command\nprogram\n .command('pipeline')\n .description('Show pipeline details and recent builds')\n .argument('<reference>', 'Pipeline reference (org/pipeline or URL)')\n .option('-n, --count <n>', 'Number of recent builds to show', '20')\n .action(async function(this: ExtendedCommand, reference: string) {\n try {\n const options = this.mergedOptions || this.opts();\n const token = await BaseCommand.getToken(options);\n \n const handler = new ShowPipeline({\n token,\n debug: options.debug,\n format: options.format,\n quiet: options.quiet,\n tips: options.tips,\n });\n \n const exitCode = await handler.execute({\n ...options,\n reference,\n count: options.count ? parseInt(options.count) : 20,\n });\n \n process.exitCode = exitCode;\n } catch (error) {\n const debug = this.mergedOptions?.debug || this.opts().debug || false;\n displayCLIError(error, debug);\n process.exitCode = 1;\n }\n });\n\n// Add logs command\nprogram\n .command('logs')\n .description('Show logs for a build step')\n .argument('<build-ref>', 'Build reference (org/pipeline/build or URL)')\n .argument('[step-id]', 'Step/job ID (or include in URL with ?sid=)')\n .option('--full', 'Show all log lines')\n .option('--lines <n>', 'Show last N lines', '50')\n .option('--save <path>', 'Save logs to file')\n .action(async function(this: ExtendedCommand, buildRef: string, stepId?: string) {\n try {\n const options = this.mergedOptions || this.opts();\n const token = await BaseCommand.getToken(options);\n \n const handler = new ShowLogs({\n token,\n debug: options.debug,\n format: options.format,\n quiet: options.quiet,\n tips: options.tips,\n });\n \n const exitCode = await handler.execute({\n ...options,\n buildRef,\n stepId,\n full: options.full,\n lines: options.lines ? parseInt(options.lines) : 50,\n save: options.save,\n });\n \n process.exitCode = exitCode;\n } catch (error) {\n const debug = this.mergedOptions?.debug || this.opts().debug || false;\n displayCLIError(error, debug);\n process.exitCode = 1;\n }\n });\n\n// Add completions command\nprogram\n .command('completions [shell]')\n .description('Generate shell completions')\n .action(async (shell) => {\n const handler = new GenerateCompletions();\n const exitCode = await handler.execute({ shell, quiet: program.opts().quiet, debug: program.opts().debug });\n process.exitCode = exitCode;\n });\n\nprogram\n .command('boom')\n .description('Test error handling')\n .option('--type <type>', 'Type of error to throw (basic, api, object)', 'basic')\n .option('--format <format>', 'Output format (plain, json, alfred)', 'plain')\n .action((options) => {\n switch (options.type) {\n case 'api':\n const apiError = new Error('API request failed');\n (apiError as any).response = {\n errors: [\n { message: 'Invalid token', path: ['viewer'] }\n ]\n };\n throw apiError;\n \n case 'object':\n throw {\n message: 'This is not an Error instance',\n code: 'CUSTOM_ERROR'\n };\n \n case 'basic':\n default:\n throw new Error('Boom! This is a test error');\n }\n });\n\n// Apply log level from command line options before parsing\nconst options = program.opts();\nif (options.debug) {\n // Debug mode takes precedence over log-level\n setLogLevel('debug');\n logger.debug('Debug mode enabled via --debug flag');\n} else if (options.logLevel) {\n setLogLevel(options.logLevel);\n logger.debug(`Log level set to ${options.logLevel} via --log-level option`);\n}\n\nlogger.debug({ \n pid: process.pid, \n}, 'Buildkite CLI started');\n\n// Handle unknown commands by trying to parse as Buildkite references\nprogram.on('command:*', (operands) => {\n const potentialReference = operands[0];\n \n (async () => {\n try {\n const { parseBuildkiteReference } = await import('./utils/parseBuildkiteReference.js');\n \n // Try to parse as Buildkite reference (will throw if invalid)\n parseBuildkiteReference(potentialReference);\n \n // If parsing succeeds, route to SmartShow\n const token = await BaseCommand.getToken(options);\n const smartShowCommand = new SmartShow();\n \n const smartShowOptions = {\n reference: potentialReference,\n token,\n format: options.format,\n debug: options.debug,\n full: options.full,\n lines: options.lines ? parseInt(options.lines) : undefined,\n save: options.save,\n cache: options.cache !== false,\n cacheTtl: options.cacheTtl,\n clearCache: options.clearCache,\n quiet: options.quiet,\n tips: options.tips,\n };\n \n const exitCode = await smartShowCommand.execute(smartShowOptions);\n process.exit(exitCode);\n } catch (parseError) {\n // If parsing fails, show unknown command error\n logger.error(`Unknown command: ${potentialReference}`);\n logger.error(`Run 'bktide --help' for usage information`);\n process.exit(1);\n }\n })();\n});\n\n// Parse command line arguments\nprogram.parse(); "]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bktide",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1769039233",
|
|
4
4
|
"description": "Command-line interface for Buildkite CI/CD workflows with rich shell completions (Fish, Bash, Zsh) and Alfred workflow integration for macOS power users",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|