bktide 1.0.1765203819 → 1.0.1765378562
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/SmartShow.js +250 -0
- package/dist/commands/SmartShow.js.map +1 -0
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/formatters/pipeline-detail/AlfredFormatter.js +57 -0
- package/dist/formatters/pipeline-detail/AlfredFormatter.js.map +1 -0
- package/dist/formatters/pipeline-detail/Formatter.js +7 -0
- package/dist/formatters/pipeline-detail/Formatter.js.map +1 -0
- package/dist/formatters/pipeline-detail/JsonFormatter.js +11 -0
- package/dist/formatters/pipeline-detail/JsonFormatter.js.map +1 -0
- package/dist/formatters/pipeline-detail/PlainFormatter.js +55 -0
- package/dist/formatters/pipeline-detail/PlainFormatter.js.map +1 -0
- package/dist/formatters/pipeline-detail/index.js +5 -0
- package/dist/formatters/pipeline-detail/index.js.map +1 -0
- package/dist/formatters/step-logs/AlfredFormatter.js +72 -0
- package/dist/formatters/step-logs/AlfredFormatter.js.map +1 -0
- package/dist/formatters/step-logs/Formatter.js +7 -0
- package/dist/formatters/step-logs/Formatter.js.map +1 -0
- package/dist/formatters/step-logs/JsonFormatter.js +11 -0
- package/dist/formatters/step-logs/JsonFormatter.js.map +1 -0
- package/dist/formatters/step-logs/PlainFormatter.js +47 -0
- package/dist/formatters/step-logs/PlainFormatter.js.map +1 -0
- package/dist/formatters/step-logs/index.js +5 -0
- package/dist/formatters/step-logs/index.js.map +1 -0
- package/dist/graphql/queries.js +22 -0
- package/dist/graphql/queries.js.map +1 -1
- package/dist/index.js +45 -4
- package/dist/index.js.map +1 -1
- package/dist/services/BuildkiteClient.js +18 -1
- package/dist/services/BuildkiteClient.js.map +1 -1
- package/dist/services/BuildkiteRestClient.js +73 -0
- package/dist/services/BuildkiteRestClient.js.map +1 -1
- package/dist/types/buildkite.js.map +1 -1
- package/dist/utils/formatUtils.js +91 -0
- package/dist/utils/formatUtils.js.map +1 -0
- package/dist/utils/parseBuildkiteReference.js +93 -0
- package/dist/utils/parseBuildkiteReference.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonFormatter.js","sourceRoot":"/","sources":["formatters/step-logs/JsonFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA0C,MAAM,gBAAgB,CAAC;AAE3F,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IAC1D,IAAI,GAAG,MAAM,CAAC;IAEd,YAAY,OAAiC;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,IAAkB;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC;CACF","sourcesContent":["import { StepLogsFormatter, StepLogsData, StepLogsFormatterOptions } from './Formatter.js';\n\nexport class JsonStepLogsFormatter extends StepLogsFormatter {\n name = 'json';\n\n constructor(options: StepLogsFormatterOptions) {\n super(options);\n }\n\n format(data: StepLogsData): string {\n return JSON.stringify(data, null, 2);\n }\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { StepLogsFormatter } from './Formatter.js';
|
|
2
|
+
import { SEMANTIC_COLORS } from '../../ui/theme.js';
|
|
3
|
+
import { formatStatus, formatRelativeDate, formatDuration, formatSize } from '../../utils/formatUtils.js';
|
|
4
|
+
export class PlainStepLogsFormatter extends StepLogsFormatter {
|
|
5
|
+
name = 'plain';
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(options);
|
|
8
|
+
}
|
|
9
|
+
format(data) {
|
|
10
|
+
const { build, step, logs } = data;
|
|
11
|
+
const lines = [];
|
|
12
|
+
// Build context header
|
|
13
|
+
lines.push(SEMANTIC_COLORS.heading(`Build: ${build.org}/${build.pipeline} #${build.number}`));
|
|
14
|
+
lines.push(SEMANTIC_COLORS.dim(`Status: ${formatStatus(build.state)}`));
|
|
15
|
+
if (build.startedAt) {
|
|
16
|
+
lines.push(SEMANTIC_COLORS.dim(`Started: ${formatRelativeDate(build.startedAt)}`));
|
|
17
|
+
}
|
|
18
|
+
if (build.finishedAt && build.startedAt) {
|
|
19
|
+
const duration = formatDuration(build.startedAt, build.finishedAt);
|
|
20
|
+
lines.push(SEMANTIC_COLORS.dim(`Duration: ${duration}`));
|
|
21
|
+
}
|
|
22
|
+
lines.push('');
|
|
23
|
+
// Step information
|
|
24
|
+
lines.push(SEMANTIC_COLORS.subheading(`Step: ${step.label || 'Unnamed Step'}`));
|
|
25
|
+
lines.push(SEMANTIC_COLORS.dim(`Job ID: ${step.id}`));
|
|
26
|
+
lines.push(SEMANTIC_COLORS.dim(`State: ${step.state}`));
|
|
27
|
+
if (step.exitStatus !== undefined) {
|
|
28
|
+
lines.push(SEMANTIC_COLORS.dim(`Exit Status: ${step.exitStatus}`));
|
|
29
|
+
}
|
|
30
|
+
lines.push('');
|
|
31
|
+
// Logs
|
|
32
|
+
lines.push(SEMANTIC_COLORS.subheading(`Logs (last ${logs.displayedLines} lines of ${logs.totalLines}):`));
|
|
33
|
+
lines.push(SEMANTIC_COLORS.dim('─'.repeat(60)));
|
|
34
|
+
lines.push(logs.content);
|
|
35
|
+
lines.push(SEMANTIC_COLORS.dim('─'.repeat(60)));
|
|
36
|
+
lines.push('');
|
|
37
|
+
// Tips
|
|
38
|
+
if (logs.displayedLines < logs.totalLines) {
|
|
39
|
+
const sizeFormatted = formatSize(logs.size);
|
|
40
|
+
lines.push(SEMANTIC_COLORS.tip(`→ Log is ${sizeFormatted}. Showing last ${logs.displayedLines} lines.`));
|
|
41
|
+
lines.push(SEMANTIC_COLORS.tip(`→ Run with --full to see all ${logs.totalLines} lines`));
|
|
42
|
+
lines.push(SEMANTIC_COLORS.tip(`→ Run with --save <path> to save to file`));
|
|
43
|
+
}
|
|
44
|
+
return lines.join('\n');
|
|
45
|
+
}
|
|
46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AAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAC1C,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5C,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,YAAY,aAAa,kBAAkB,IAAI,CAAC,cAAc,SAAS,CAAC,CAAC,CAAC;YACzG,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,gCAAgC,IAAI,CAAC,UAAU,QAAQ,CAAC,CAAC,CAAC;YACzF,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF","sourcesContent":["import { StepLogsFormatter, StepLogsData, StepLogsFormatterOptions } from './Formatter.js';\nimport { SEMANTIC_COLORS } from '../../ui/theme.js';\nimport { formatStatus, formatRelativeDate, formatDuration, formatSize } from '../../utils/formatUtils.js';\n\nexport class PlainStepLogsFormatter extends StepLogsFormatter {\n name = 'plain';\n\n constructor(options: StepLogsFormatterOptions) {\n super(options);\n }\n\n format(data: StepLogsData): string {\n const { build, step, logs } = data;\n const lines: string[] = [];\n\n // Build context header\n lines.push(SEMANTIC_COLORS.heading(`Build: ${build.org}/${build.pipeline} #${build.number}`));\n lines.push(SEMANTIC_COLORS.dim(`Status: ${formatStatus(build.state)}`));\n \n if (build.startedAt) {\n lines.push(SEMANTIC_COLORS.dim(`Started: ${formatRelativeDate(build.startedAt)}`));\n }\n \n if (build.finishedAt && build.startedAt) {\n const duration = formatDuration(build.startedAt, build.finishedAt);\n lines.push(SEMANTIC_COLORS.dim(`Duration: ${duration}`));\n }\n \n lines.push('');\n\n // Step information\n lines.push(SEMANTIC_COLORS.subheading(`Step: ${step.label || 'Unnamed Step'}`));\n lines.push(SEMANTIC_COLORS.dim(`Job ID: ${step.id}`));\n lines.push(SEMANTIC_COLORS.dim(`State: ${step.state}`));\n \n if (step.exitStatus !== undefined) {\n lines.push(SEMANTIC_COLORS.dim(`Exit Status: ${step.exitStatus}`));\n }\n \n lines.push('');\n\n // Logs\n lines.push(SEMANTIC_COLORS.subheading(`Logs (last ${logs.displayedLines} lines of ${logs.totalLines}):`));\n lines.push(SEMANTIC_COLORS.dim('─'.repeat(60)));\n lines.push(logs.content);\n lines.push(SEMANTIC_COLORS.dim('─'.repeat(60)));\n lines.push('');\n\n // Tips\n if (logs.displayedLines < logs.totalLines) {\n const sizeFormatted = formatSize(logs.size);\n lines.push(SEMANTIC_COLORS.tip(`→ Log is ${sizeFormatted}. Showing last ${logs.displayedLines} lines.`));\n lines.push(SEMANTIC_COLORS.tip(`→ Run with --full to see all ${logs.totalLines} lines`));\n lines.push(SEMANTIC_COLORS.tip(`→ Run with --save <path> to save to file`));\n }\n\n return lines.join('\\n');\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["formatters/step-logs/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC","sourcesContent":["export * from './Formatter.js';\nexport * from './PlainFormatter.js';\nexport * from './JsonFormatter.js';\nexport * from './AlfredFormatter.js';\n"]}
|
package/dist/graphql/queries.js
CHANGED
|
@@ -56,6 +56,28 @@ export const GET_PIPELINES = gql `
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
`;
|
|
59
|
+
export const GET_PIPELINE = gql `
|
|
60
|
+
query GetPipeline($organizationSlug: ID!, $pipelineSlug: String!) {
|
|
61
|
+
organization(slug: $organizationSlug) {
|
|
62
|
+
pipelines(first: 1, search: $pipelineSlug) {
|
|
63
|
+
edges {
|
|
64
|
+
node {
|
|
65
|
+
uuid
|
|
66
|
+
id
|
|
67
|
+
name
|
|
68
|
+
slug
|
|
69
|
+
description
|
|
70
|
+
url
|
|
71
|
+
defaultBranch
|
|
72
|
+
repository {
|
|
73
|
+
url
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
59
81
|
export const GET_BUILDS = gql `
|
|
60
82
|
query GetBuilds($pipelineSlug: String!, $organizationSlug: ID!, $first: Int) {
|
|
61
83
|
organization(slug: $organizationSlug) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.js","sourceRoot":"/","sources":["graphql/queries.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE7E,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;;;;;;;;;;;;CAY5B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;CAcnC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;CAwB/B,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+B5B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BnC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;CAgBvC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiEhC,kBAAkB;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyE7B,iBAAiB;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;IAkBlC,kBAAkB;CACrB,CAAC","sourcesContent":["/**\n * Common GraphQL queries for the Buildkite API\n */\nimport { gql } from 'graphql-request';\nimport { JOB_SUMMARY_FIELDS, JOB_DETAIL_FIELDS } from './fragments/index.js';\n\nexport const GET_VIEWER = gql`\n query GetViewer {\n viewer {\n id\n user {\n id\n uuid\n name\n email\n }\n }\n }\n`;\n\nexport const GET_ORGANIZATIONS = gql`\n query GetOrganizations {\n viewer {\n organizations {\n edges {\n node {\n id\n name\n slug\n }\n }\n }\n }\n }\n`;\n\nexport const GET_PIPELINES = gql`\n query GetPipelines($organizationSlug: ID!, $first: Int, $after: String) {\n organization(slug: $organizationSlug) {\n pipelines(first: $first, after: $after, archived: false) {\n edges {\n node {\n uuid\n id\n name\n slug\n description\n url\n repository {\n url\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n`;\n\nexport const GET_BUILDS = gql`\n query GetBuilds($pipelineSlug: String!, $organizationSlug: ID!, $first: Int) {\n organization(slug: $organizationSlug) {\n pipelines(first: 1, search: $pipelineSlug) {\n edges {\n node {\n builds(first: $first) {\n edges {\n node {\n id\n number\n url\n state\n message\n commit\n branch\n createdAt\n startedAt\n finishedAt\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n }\n }\n }\n`;\n\nexport const GET_VIEWER_BUILDS = gql`\n query GetViewerBuilds($first: Int!) {\n viewer {\n builds(first: $first) {\n edges {\n node {\n id\n number\n state\n url\n createdAt\n branch\n message\n pipeline {\n name\n slug\n }\n organization {\n name\n slug\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n`;\n\nexport const GET_BUILD_ANNOTATIONS = gql`\n query GetBuildAnnotations($buildSlug: ID!) {\n build(slug: $buildSlug) {\n annotations(first: 100) {\n edges {\n node {\n context\n style\n body {\n html\n }\n }\n }\n }\n }\n }\n`;\n\nexport const GET_BUILD_SUMMARY = gql`\n query GetBuildSummary($slug: ID!) {\n build(slug: $slug) {\n id\n number\n state\n branch\n message\n commit\n createdAt\n startedAt\n finishedAt\n canceledAt\n url\n blockedState\n createdBy {\n ... on User {\n id\n name\n email\n avatar {\n url\n }\n }\n ... on UnregisteredUser {\n name\n email\n }\n }\n pipeline {\n id\n name\n slug\n }\n organization {\n id\n name\n slug\n }\n jobs(first: 100) {\n edges {\n node {\n ...JobSummaryFields\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n count\n }\n annotations(first: 50) {\n edges {\n node {\n id\n style\n context\n body {\n html\n }\n }\n }\n }\n }\n }\n ${JOB_SUMMARY_FIELDS}\n`;\n\nexport const GET_BUILD_FULL = gql`\n query GetBuildFull($slug: ID!) {\n build(slug: $slug) {\n id\n number\n state\n branch\n message\n commit\n createdAt\n startedAt\n finishedAt\n canceledAt\n url\n blockedState\n createdBy {\n ... on User {\n id\n name\n email\n avatar {\n url\n }\n }\n ... on UnregisteredUser {\n name\n email\n }\n }\n pipeline {\n id\n name\n slug\n repository {\n url\n }\n }\n organization {\n id\n name\n slug\n }\n pullRequest {\n id\n }\n jobs(first: 100) {\n edges {\n node {\n ...JobDetailFields\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n count\n }\n annotations(first: 100) {\n edges {\n node {\n id\n style\n context\n body {\n html\n }\n createdAt\n updatedAt\n }\n }\n }\n }\n }\n ${JOB_DETAIL_FIELDS}\n`;\n\nexport const GET_BUILD_JOBS_PAGE = gql`\n query GetBuildJobsPage($slug: ID!, $first: Int!, $after: String) {\n build(slug: $slug) {\n id\n jobs(first: $first, after: $after) {\n edges {\n node {\n ...JobSummaryFields\n }\n }\n pageInfo {\n hasNextPage\n endCurs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AG,CAAA;;;;;;;;;;;;;;;;;;IAkBlC,kBAAkB;CACrB,CAAC","sourcesContent":["/**\n * Common GraphQL queries for the Buildkite API\n */\nimport { gql } from 'graphql-request';\nimport { JOB_SUMMARY_FIELDS, JOB_DETAIL_FIELDS } from './fragments/index.js';\n\nexport const GET_VIEWER = gql`\n query GetViewer {\n viewer {\n id\n user {\n id\n uuid\n name\n email\n }\n }\n }\n`;\n\nexport const GET_ORGANIZATIONS = gql`\n query GetOrganizations {\n viewer {\n organizations {\n edges {\n node {\n id\n name\n slug\n }\n }\n }\n }\n }\n`;\n\nexport const GET_PIPELINES = gql`\n query GetPipelines($organizationSlug: ID!, $first: Int, $after: String) {\n organization(slug: $organizationSlug) {\n pipelines(first: $first, after: $after, archived: false) {\n edges {\n node {\n uuid\n id\n name\n slug\n description\n url\n repository {\n url\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n`;\n\nexport const GET_PIPELINE = gql`\n query GetPipeline($organizationSlug: ID!, $pipelineSlug: String!) {\n organization(slug: $organizationSlug) {\n pipelines(first: 1, search: $pipelineSlug) {\n edges {\n node {\n uuid\n id\n name\n slug\n description\n url\n defaultBranch\n repository {\n url\n }\n }\n }\n }\n }\n }\n`;\n\nexport const GET_BUILDS = gql`\n query GetBuilds($pipelineSlug: String!, $organizationSlug: ID!, $first: Int) {\n organization(slug: $organizationSlug) {\n pipelines(first: 1, search: $pipelineSlug) {\n edges {\n node {\n builds(first: $first) {\n edges {\n node {\n id\n number\n url\n state\n message\n commit\n branch\n createdAt\n startedAt\n finishedAt\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n }\n }\n }\n`;\n\nexport const GET_VIEWER_BUILDS = gql`\n query GetViewerBuilds($first: Int!) {\n viewer {\n builds(first: $first) {\n edges {\n node {\n id\n number\n state\n url\n createdAt\n branch\n message\n pipeline {\n name\n slug\n }\n organization {\n name\n slug\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n`;\n\nexport const GET_BUILD_ANNOTATIONS = gql`\n query GetBuildAnnotations($buildSlug: ID!) {\n build(slug: $buildSlug) {\n annotations(first: 100) {\n edges {\n node {\n context\n style\n body {\n html\n }\n }\n }\n }\n }\n }\n`;\n\nexport const GET_BUILD_SUMMARY = gql`\n query GetBuildSummary($slug: ID!) {\n build(slug: $slug) {\n id\n number\n state\n branch\n message\n commit\n createdAt\n startedAt\n finishedAt\n canceledAt\n url\n blockedState\n createdBy {\n ... on User {\n id\n name\n email\n avatar {\n url\n }\n }\n ... on UnregisteredUser {\n name\n email\n }\n }\n pipeline {\n id\n name\n slug\n }\n organization {\n id\n name\n slug\n }\n jobs(first: 100) {\n edges {\n node {\n ...JobSummaryFields\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n count\n }\n annotations(first: 50) {\n edges {\n node {\n id\n style\n context\n body {\n html\n }\n }\n }\n }\n }\n }\n ${JOB_SUMMARY_FIELDS}\n`;\n\nexport const GET_BUILD_FULL = gql`\n query GetBuildFull($slug: ID!) {\n build(slug: $slug) {\n id\n number\n state\n branch\n message\n commit\n createdAt\n startedAt\n finishedAt\n canceledAt\n url\n blockedState\n createdBy {\n ... on User {\n id\n name\n email\n avatar {\n url\n }\n }\n ... on UnregisteredUser {\n name\n email\n }\n }\n pipeline {\n id\n name\n slug\n repository {\n url\n }\n }\n organization {\n id\n name\n slug\n }\n pullRequest {\n id\n }\n jobs(first: 100) {\n edges {\n node {\n ...JobDetailFields\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n count\n }\n annotations(first: 100) {\n edges {\n node {\n id\n style\n context\n body {\n html\n }\n createdAt\n updatedAt\n }\n }\n }\n }\n }\n ${JOB_DETAIL_FIELDS}\n`;\n\nexport const GET_BUILD_JOBS_PAGE = gql`\n query GetBuildJobsPage($slug: ID!, $first: Int!, $after: String) {\n build(slug: $slug) {\n id\n jobs(first: $first, after: $after) {\n edges {\n node {\n ...JobSummaryFields\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n count\n }\n }\n }\n ${JOB_SUMMARY_FIELDS}\n`; "]}
|
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 } from './commands/index.js';
|
|
6
|
+
import { BaseCommand, ShowViewer, ListOrganizations, ListBuilds, ListPipelines, ManageToken, ListAnnotations, GenerateCompletions, ShowBuild, 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';
|
|
@@ -35,6 +35,7 @@ process.on('unhandledRejection', unhandledRejectionHandler);
|
|
|
35
35
|
// Initialize error handling after our handlers are registered
|
|
36
36
|
initializeErrorHandling();
|
|
37
37
|
const program = new Command();
|
|
38
|
+
program.allowUnknownOption();
|
|
38
39
|
// Handler for executing commands with proper option handling
|
|
39
40
|
const createCommandHandler = (CommandClass) => {
|
|
40
41
|
return async function () {
|
|
@@ -121,7 +122,10 @@ program
|
|
|
121
122
|
.option('-q, --quiet', 'Suppress non-error output (plain format only)')
|
|
122
123
|
.option('--tips', 'Show helpful tips and suggestions')
|
|
123
124
|
.option('--no-tips', 'Hide helpful tips and suggestions')
|
|
124
|
-
.option('--ascii', 'Use ASCII symbols instead of Unicode')
|
|
125
|
+
.option('--ascii', 'Use ASCII symbols instead of Unicode')
|
|
126
|
+
.option('--full', 'Show all log lines (for step logs)')
|
|
127
|
+
.option('--lines <n>', 'Show last N lines (default: 50)', '50')
|
|
128
|
+
.option('--save <path>', 'Save logs to file');
|
|
125
129
|
// Add hooks for handling options
|
|
126
130
|
program
|
|
127
131
|
.hook('preAction', (_thisCommand, actionCommand) => {
|
|
@@ -315,8 +319,7 @@ program
|
|
|
315
319
|
throw new Error('Boom! This is a test error');
|
|
316
320
|
}
|
|
317
321
|
});
|
|
318
|
-
|
|
319
|
-
// Apply log level from command line options
|
|
322
|
+
// Apply log level from command line options before parsing
|
|
320
323
|
const options = program.opts();
|
|
321
324
|
if (options.debug) {
|
|
322
325
|
// Debug mode takes precedence over log-level
|
|
@@ -330,4 +333,42 @@ else if (options.logLevel) {
|
|
|
330
333
|
logger.debug({
|
|
331
334
|
pid: process.pid,
|
|
332
335
|
}, 'Buildkite CLI started');
|
|
336
|
+
// Handle unknown commands by trying to parse as Buildkite references
|
|
337
|
+
program.on('command:*', (operands) => {
|
|
338
|
+
const potentialReference = operands[0];
|
|
339
|
+
(async () => {
|
|
340
|
+
try {
|
|
341
|
+
const { parseBuildkiteReference } = await import('./utils/parseBuildkiteReference.js');
|
|
342
|
+
// Try to parse as Buildkite reference (will throw if invalid)
|
|
343
|
+
parseBuildkiteReference(potentialReference);
|
|
344
|
+
// If parsing succeeds, route to SmartShow
|
|
345
|
+
const token = await BaseCommand.getToken(options);
|
|
346
|
+
const smartShowCommand = new SmartShow();
|
|
347
|
+
const smartShowOptions = {
|
|
348
|
+
reference: potentialReference,
|
|
349
|
+
token,
|
|
350
|
+
format: options.format,
|
|
351
|
+
debug: options.debug,
|
|
352
|
+
full: options.full,
|
|
353
|
+
lines: options.lines ? parseInt(options.lines) : undefined,
|
|
354
|
+
save: options.save,
|
|
355
|
+
cache: options.cache !== false,
|
|
356
|
+
cacheTtl: options.cacheTtl,
|
|
357
|
+
clearCache: options.clearCache,
|
|
358
|
+
quiet: options.quiet,
|
|
359
|
+
tips: options.tips,
|
|
360
|
+
};
|
|
361
|
+
const exitCode = await smartShowCommand.execute(smartShowOptions);
|
|
362
|
+
process.exit(exitCode);
|
|
363
|
+
}
|
|
364
|
+
catch (parseError) {
|
|
365
|
+
// If parsing fails, show unknown command error
|
|
366
|
+
logger.error(`Unknown command: ${potentialReference}`);
|
|
367
|
+
logger.error(`Run 'bktide --help' for usage information`);
|
|
368
|
+
process.exit(1);
|
|
369
|
+
}
|
|
370
|
+
})();
|
|
371
|
+
});
|
|
372
|
+
// Parse command line arguments
|
|
373
|
+
program.parse();
|
|
333
374
|
//# sourceMappingURL=index.js.map
|
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,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,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,QAAQ,yBAAyB,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,CAAC,KAAK,CAAC;IACX,GAAG,EAAE,OAAO,CAAC,GAAG;CACjB,EAAE,uBAAuB,CAAC,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} 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();\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\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\nprogram.parse();\n\n// Apply log level from command line options\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'); "]}
|
|
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,OAA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;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(); "]}
|
|
@@ -2,7 +2,7 @@ import { GraphQLClient } from 'graphql-request';
|
|
|
2
2
|
import { CacheManager } from './CacheManager.js';
|
|
3
3
|
import { getProgressIcon } from '../ui/theme.js';
|
|
4
4
|
// Import the queries - we'll use them for both string queries and typed SDK
|
|
5
|
-
import { GET_VIEWER, GET_ORGANIZATIONS, GET_PIPELINES, GET_BUILDS, GET_VIEWER_BUILDS, GET_BUILD_ANNOTATIONS, GET_BUILD_SUMMARY, GET_BUILD_FULL, GET_BUILD_JOBS_PAGE } from '../graphql/queries.js';
|
|
5
|
+
import { GET_VIEWER, GET_ORGANIZATIONS, GET_PIPELINES, GET_PIPELINE, GET_BUILDS, GET_VIEWER_BUILDS, GET_BUILD_ANNOTATIONS, GET_BUILD_SUMMARY, GET_BUILD_FULL, GET_BUILD_JOBS_PAGE } from '../graphql/queries.js';
|
|
6
6
|
import { logger } from './logger.js';
|
|
7
7
|
/**
|
|
8
8
|
* BuildkiteClient provides methods to interact with the Buildkite GraphQL API
|
|
@@ -401,6 +401,23 @@ export class BuildkiteClient {
|
|
|
401
401
|
}
|
|
402
402
|
return result;
|
|
403
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* Get a single pipeline by organization and pipeline slug
|
|
406
|
+
*/
|
|
407
|
+
async getPipeline(orgSlug, pipelineSlug) {
|
|
408
|
+
const variables = {
|
|
409
|
+
organizationSlug: orgSlug,
|
|
410
|
+
pipelineSlug: pipelineSlug,
|
|
411
|
+
};
|
|
412
|
+
if (this.debug) {
|
|
413
|
+
logger.debug('Fetching pipeline:', variables);
|
|
414
|
+
}
|
|
415
|
+
const data = await this.query(GET_PIPELINE.toString(), variables);
|
|
416
|
+
if (this.debug) {
|
|
417
|
+
logger.debug('Pipeline data:', data);
|
|
418
|
+
}
|
|
419
|
+
return data.organization?.pipelines?.edges?.[0]?.node;
|
|
420
|
+
}
|
|
404
421
|
/**
|
|
405
422
|
* Get builds for a pipeline with type safety
|
|
406
423
|
* @param pipelineSlug The pipeline slug
|