bktide 1.0.1755267617 → 1.0.1755547716
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 +107 -1
- package/WORKFLOW_README.md +1 -1
- package/completions/bktide-dynamic.fish +171 -0
- package/completions/bktide.bash +124 -0
- package/completions/bktide.fish +107 -0
- package/completions/bktide.zsh +139 -0
- package/dist/commands/BaseCommand.js +7 -7
- package/dist/commands/BaseCommand.js.map +1 -1
- package/dist/commands/GenerateCompletions.js +238 -0
- package/dist/commands/GenerateCompletions.js.map +1 -0
- package/dist/commands/ListAnnotations.js +7 -0
- package/dist/commands/ListAnnotations.js.map +1 -1
- package/dist/commands/ListBuilds.js +67 -3
- package/dist/commands/ListBuilds.js.map +1 -1
- package/dist/commands/ListOrganizations.js +6 -0
- package/dist/commands/ListOrganizations.js.map +1 -1
- package/dist/commands/ListPipelines.js +87 -12
- package/dist/commands/ListPipelines.js.map +1 -1
- package/dist/commands/ManageToken.js +32 -9
- package/dist/commands/ManageToken.js.map +1 -1
- package/dist/commands/ShowViewer.js +7 -1
- package/dist/commands/ShowViewer.js.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/formatters/annotations/PlainTextFormatter.js +37 -9
- package/dist/formatters/annotations/PlainTextFormatter.js.map +1 -1
- package/dist/formatters/builds/PlainTextFormatter.js +82 -60
- package/dist/formatters/builds/PlainTextFormatter.js.map +1 -1
- package/dist/formatters/errors/AlfredFormatter.js +20 -0
- package/dist/formatters/errors/AlfredFormatter.js.map +1 -1
- package/dist/formatters/errors/PlainTextFormatter.js +121 -23
- package/dist/formatters/errors/PlainTextFormatter.js.map +1 -1
- package/dist/formatters/organizations/PlainTextFormatter.js +37 -6
- package/dist/formatters/organizations/PlainTextFormatter.js.map +1 -1
- package/dist/formatters/pipelines/AlfredFormatter.js.map +1 -1
- package/dist/formatters/pipelines/Formatter.js.map +1 -1
- package/dist/formatters/pipelines/JsonFormatter.js.map +1 -1
- package/dist/formatters/pipelines/PlainTextFormatter.js +165 -19
- package/dist/formatters/pipelines/PlainTextFormatter.js.map +1 -1
- package/dist/formatters/token/AlfredFormatter.js +15 -2
- package/dist/formatters/token/AlfredFormatter.js.map +1 -1
- package/dist/formatters/token/PlainTextFormatter.js +56 -18
- package/dist/formatters/token/PlainTextFormatter.js.map +1 -1
- package/dist/formatters/viewer/PlainTextFormatter.js +8 -7
- package/dist/formatters/viewer/PlainTextFormatter.js.map +1 -1
- package/dist/index.js +47 -6
- package/dist/index.js.map +1 -1
- package/dist/services/CredentialManager.js +80 -10
- package/dist/services/CredentialManager.js.map +1 -1
- package/dist/ui/help.js +69 -0
- package/dist/ui/help.js.map +1 -0
- package/dist/ui/progress.js +356 -0
- package/dist/ui/progress.js.map +1 -0
- package/dist/ui/reporter.js +111 -0
- package/dist/ui/reporter.js.map +1 -0
- package/dist/ui/responsive-table.js +183 -0
- package/dist/ui/responsive-table.js.map +1 -0
- package/dist/ui/spinner.js +20 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/symbols.js +46 -0
- package/dist/ui/symbols.js.map +1 -0
- package/dist/ui/table.js +32 -0
- package/dist/ui/table.js.map +1 -0
- package/dist/ui/theme.js +280 -0
- package/dist/ui/theme.js.map +1 -0
- package/dist/ui/width.js +111 -0
- package/dist/ui/width.js.map +1 -0
- package/dist/utils/alfred.js +6 -0
- package/dist/utils/alfred.js.map +1 -0
- package/dist/utils/cli-error-handler.js +35 -20
- package/dist/utils/cli-error-handler.js.map +1 -1
- package/dist/utils/pagination.js +92 -0
- package/dist/utils/pagination.js.map +1 -0
- package/info.plist +51 -218
- package/package.json +23 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlfredFormatter.js","sourceRoot":"/","sources":["formatters/token/AlfredFormatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AASpD;;GAEG;AACH,MAAM,OAAO,e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AAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAC/C,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC3B,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,GAAG,UAAU;aACzD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import { TokenStatus, TokenValidationStatus } from '../../types/credentials.js';\nimport { BaseTokenFormatter } from './Formatter.js';\n\ninterface AlfredItem {\n title: string;\n subtitle: string;\n icon: string;\n arg: string;\n}\n\n/**\n * Alfred formatter for tokens\n */\nexport class AlfredFormatter extends BaseTokenFormatter {\n name = 'alfred';\n\n /**\n * Format token status information for Alfred\n * \n * @param status The token status information\n * @returns Formatted token status message for Alfred\n */\n formatTokenStatus(status: TokenStatus): string {\n const items = this.formatTokenStatusAsItems(status);\n return JSON.stringify({ items });\n }\n\n /**\n * Format token storage result for Alfred\n * \n * @param success Whether the token was successfully stored\n * @returns Formatted token storage result message for Alfred\n */\n formatTokenStorageResult(success: boolean): string {\n const items: AlfredItem[] = [{\n title: success ? 'Token Stored Successfully' : 'Failed to Store Token',\n subtitle: success ? 'Token was saved to system keychain' : 'Could not save token to system keychain',\n icon: this.getIcon(success),\n arg: success ? 'token:stored' : 'token:store-failed'\n }];\n return JSON.stringify({ items });\n }\n\n /**\n * Format token reset result for Alfred\n * \n * @param success Whether the token was successfully reset\n * @param hadToken Whether there was a token before reset\n * @returns Formatted token reset result message for Alfred\n */\n formatTokenResetResult(success: boolean, hadToken: boolean): string {\n const items: AlfredItem[] = [{\n title: success ? 'Token Reset Successfully' : 'Failed to Reset Token',\n subtitle: success \n ? hadToken \n ? 'Token was removed from system keychain' \n : 'No token was present to reset'\n : 'Could not remove token from system keychain',\n icon: this.getIcon(success),\n arg: success ? 'token:reset' : 'token:reset-failed'\n }];\n return JSON.stringify({ items });\n }\n\n /**\n * Format token validation error for Alfred\n * \n * @param validation The validation status for each API\n * @returns Formatted token validation error message for Alfred\n */\n formatTokenValidationError(validation: TokenValidationStatus): string {\n const items = this.formatTokenValidationStatusAsItems(validation);\n return JSON.stringify({ items });\n }\n\n /**\n * Format token validation status for Alfred\n * \n * @param validation The validation status for each API\n * @returns Formatted token validation status message for Alfred\n */\n formatTokenValidationStatus(validation: TokenValidationStatus): string {\n const items = this.formatTokenValidationStatusAsItems(validation);\n return JSON.stringify({ items });\n }\n\n /**\n * Format error message(s) for Alfred\n * \n * @param operation The operation that failed (e.g., 'storing', 'resetting', 'validating')\n * @param error The error that occurred, or an array of errors\n * @returns Formatted error message(s) for Alfred\n */\n formatError(operation: string, error: unknown | unknown[]): string {\n const errors = Array.isArray(error) ? error : [error];\n const items: AlfredItem[] = errors.map(err => ({\n title: `Error during ${operation}`,\n subtitle: err instanceof Error ? err.message : String(err),\n icon: this.getIcon(false),\n arg: `error:${operation}`\n }));\n return JSON.stringify({ items });\n }\n\n /**\n * Format authentication error message(s) for Alfred\n * \n * @param operation The authentication operation that failed (e.g., 'storing', 'validating')\n * @param error The authentication error that occurred, or an array of errors\n * @returns Formatted authentication error message(s) for Alfred\n */\n formatAuthErrors(operation: string, error: unknown | unknown[]): string {\n const errors = Array.isArray(error) ? error : [error];\n const items: AlfredItem[] = errors.map(err => ({\n title: `Authentication Error during ${operation}`,\n subtitle: err instanceof Error ? err.message : String(err),\n icon: this.getIcon(false),\n arg: `auth-error:${operation}`\n }));\n return JSON.stringify({ items });\n }\n\n private getIcon(isValid: boolean): string {\n return isValid ? '✅' : '❌';\n }\n\n private formatTokenStatusAsItems(status: TokenStatus): AlfredItem[] {\n const items: AlfredItem[] = [];\n \n // Add token status item\n items.push({\n title: `Token Status: ${status.hasToken ? 'Present' : 'Not Present'}`,\n subtitle: status.hasToken ? 'Token is stored in system keychain' : 'No token found in system keychain',\n icon: this.getIcon(status.hasToken),\n arg: status.hasToken ? 'token:present' : 'token:not-present'\n });\n\n if (status.hasToken) {\n // Add overall validity item\n items.push({\n title: `Valid: ${status.isValid ? 'Yes' : 'No'}`,\n subtitle: status.isValid ? 'Token is valid for all required APIs' : 'Token has limited access',\n icon: this.getIcon(status.isValid),\n arg: status.isValid ? 'token:valid' : 'token:invalid'\n });\n\n if (status.validation.canListOrganizations) {\n // Add organization status items\n Object.entries(status.validation.organizations).forEach(([org, orgStatus]) => {\n const isValid = orgStatus.graphql && orgStatus.builds && orgStatus.organizations;\n const invalidApis = [];\n if (!orgStatus.graphql) invalidApis.push('GraphQL');\n if (!orgStatus.builds) invalidApis.push('Builds');\n if (!orgStatus.organizations) invalidApis.push('Organizations');\n \n items.push({\n title: `Organization: ${org}`,\n subtitle: isValid \n ? 'Full access to all APIs'\n : `Limited access: ${invalidApis.join(', ')}`,\n icon: this.getIcon(isValid),\n arg: isValid ? `org:${org}:valid` : `org:${org}:invalid`\n });\n });\n } else {\n items.push({\n title: 'Cannot list organizations',\n subtitle: 'Token may be invalid or lacks necessary permissions',\n icon: this.getIcon(false),\n arg: 'token:no-org-access'\n });\n }\n }\n\n return items;\n }\n\n private formatTokenValidationStatusAsItems(validation: TokenValidationStatus): AlfredItem[] {\n const items: AlfredItem[] = [];\n\n if (!validation.canListOrganizations) {\n items.push({\n title: 'Cannot list organizations',\n subtitle: 'Token may be invalid or lacks necessary permissions',\n icon: this.getIcon(false),\n arg: 'token:no-org-access'\n });\n return items;\n }\n\n // Add organization status items\n Object.entries(validation.organizations).forEach(([org, orgStatus]) => {\n const isValid = orgStatus.graphql && orgStatus.builds && orgStatus.organizations;\n const invalidApis = [];\n if (!orgStatus.graphql) invalidApis.push('GraphQL');\n if (!orgStatus.builds) invalidApis.push('Builds');\n if (!orgStatus.organizations) invalidApis.push('Organizations');\n \n items.push({\n title: `Organization: ${org}`,\n subtitle: isValid \n ? 'Full access to all APIs'\n : `Limited access: ${invalidApis.join(', ')}`,\n icon: this.getIcon(isValid),\n arg: isValid ? `org:${org}:valid` : `org:${org}:invalid`\n });\n });\n\n return items;\n }\n} "]}
|
|
1
|
+
{"version":3,"file":"AlfredFormatter.js","sourceRoot":"/","sources":["formatters/token/AlfredFormatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AASpD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,kBAAkB;IACrD,IAAI,GAAG,QAAQ,CAAC;IAEhB;;;;;OAKG;IACH,iBAAiB,CAAC,MAAmB;QACnC,MAAM,KAAK,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,wBAAwB,CAAC,OAAgB;QACvC,MAAM,KAAK,GAAiB,CAAC;gBAC3B,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,uBAAuB;gBACtE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,yCAAyC;gBACpG,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC3B,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,oBAAoB;aACrD,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACnC,CAAC;IAED;;;;;;OAMG;IACH,sBAAsB,CAAC,OAAgB,EAAE,QAAiB;QACxD,MAAM,KAAK,GAAiB,CAAC;gBAC3B,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,uBAAuB;gBACrE,QAAQ,EAAE,OAAO;oBACf,CAAC,CAAC,QAAQ;wBACR,CAAC,CAAC,wCAAwC;wBAC1C,CAAC,CA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C;QACf,CAAC;QAED,gCAAgC;QAChC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE;YACpE,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,MAAM,IAAI,SAAS,CAAC,aAAa,CAAC;YACjF,MAAM,WAAW,GAAG,EAAE,CAAC;YACvB,IAAI,CAAC,SAAS,CAAC,OAAO;gBAAE,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACpD,IAAI,CAAC,SAAS,CAAC,MAAM;gBAAE,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClD,IAAI,CAAC,SAAS,CAAC,aAAa;gBAAE,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAEhE,KAAK,CAAC,IAAI,CAAC;gBACT,KAAK,EAAE,iBAAiB,GAAG,EAAE;gBAC7B,QAAQ,EAAE,OAAO;oBACf,CAAC,CAAC,yBAAyB;oBAC3B,CAAC,CAAC,mBAAmB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAC/C,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC3B,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,GAAG,UAAU;aACzD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import { TokenStatus, TokenValidationStatus } from '../../types/credentials.js';\nimport { isRunningInAlfred } from '../../utils/alfred.js';\nimport { BaseTokenFormatter } from './Formatter.js';\n\ninterface AlfredItem {\n title: string;\n subtitle: string;\n icon: string;\n arg: string;\n}\n\n/**\n * Alfred formatter for tokens\n */\nexport class AlfredFormatter extends BaseTokenFormatter {\n name = 'alfred';\n\n /**\n * Format token status information for Alfred\n * \n * @param status The token status information\n * @returns Formatted token status message for Alfred\n */\n formatTokenStatus(status: TokenStatus): string {\n const items = this.formatTokenStatusAsItems(status);\n return JSON.stringify({ items });\n }\n\n /**\n * Format token storage result for Alfred\n * \n * @param success Whether the token was successfully stored\n * @returns Formatted token storage result message for Alfred\n */\n formatTokenStorageResult(success: boolean): string {\n const items: AlfredItem[] = [{\n title: success ? 'Token Stored Successfully' : 'Failed to Store Token',\n subtitle: success ? 'Token was saved to system keychain' : 'Could not save token to system keychain',\n icon: this.getIcon(success),\n arg: success ? 'token:stored' : 'token:store-failed'\n }];\n return JSON.stringify({ items });\n }\n\n /**\n * Format token reset result for Alfred\n * \n * @param success Whether the token was successfully reset\n * @param hadToken Whether there was a token before reset\n * @returns Formatted token reset result message for Alfred\n */\n formatTokenResetResult(success: boolean, hadToken: boolean): string {\n const items: AlfredItem[] = [{\n title: success ? 'Token Reset Successfully' : 'Failed to Reset Token',\n subtitle: success \n ? hadToken \n ? 'Token was removed from system keychain' \n : 'No token was present to reset'\n : 'Could not remove token from system keychain',\n icon: this.getIcon(success),\n arg: success ? 'token:reset' : 'token:reset-failed'\n }];\n return JSON.stringify({ items });\n }\n\n /**\n * Format token validation error for Alfred\n * \n * @param validation The validation status for each API\n * @returns Formatted token validation error message for Alfred\n */\n formatTokenValidationError(validation: TokenValidationStatus): string {\n const items = this.formatTokenValidationStatusAsItems(validation);\n return JSON.stringify({ items });\n }\n\n /**\n * Format token validation status for Alfred\n * \n * @param validation The validation status for each API\n * @returns Formatted token validation status message for Alfred\n */\n formatTokenValidationStatus(validation: TokenValidationStatus): string {\n const items = this.formatTokenValidationStatusAsItems(validation);\n return JSON.stringify({ items });\n }\n\n /**\n * Format error message(s) for Alfred\n * \n * @param operation The operation that failed (e.g., 'storing', 'resetting', 'validating')\n * @param error The error that occurred, or an array of errors\n * @returns Formatted error message(s) for Alfred\n */\n formatError(operation: string, error: unknown | unknown[]): string {\n const errors = Array.isArray(error) ? error : [error];\n const items: AlfredItem[] = errors.map(err => ({\n title: `Error during ${operation}`,\n subtitle: err instanceof Error ? err.message : String(err),\n icon: this.getIcon(false),\n arg: `error:${operation}`\n }));\n return JSON.stringify({ items });\n }\n\n /**\n * Format authentication error message(s) for Alfred\n * \n * @param operation The authentication operation that failed (e.g., 'storing', 'validating')\n * @param error The authentication error that occurred, or an array of errors\n * @returns Formatted authentication error message(s) for Alfred\n */\n formatAuthErrors(operation: string, error: unknown | unknown[]): string {\n const errors = Array.isArray(error) ? error : [error];\n const items: AlfredItem[] = errors.map(err => ({\n title: `Authentication Error during ${operation}`,\n subtitle: err instanceof Error ? err.message : String(err),\n icon: this.getIcon(false),\n arg: `auth-error:${operation}`\n }));\n return JSON.stringify({ items });\n }\n\n private getIcon(isValid: boolean): string {\n return isValid ? '✅' : '❌';\n }\n\n private formatTokenStatusAsItems(status: TokenStatus): AlfredItem[] {\n const items: AlfredItem[] = [];\n \n const inAlfred = isRunningInAlfred();\n\n // Alfred-first UX: if no token, present actionable item to open config\n if (inAlfred && !status.hasToken) {\n items.push({\n title: 'Set Buildkite token',\n subtitle: 'Open Workflow Configuration to set BUILDKITE_API_TOKEN',\n icon: 'icons/info.png',\n arg: 'alfred:open-config'\n });\n }\n\n // Add token status item with context-aware subtitle\n items.push({\n title: `Token Status: ${status.hasToken ? 'Present' : 'Not Present'}`,\n subtitle: status.hasToken\n ? (inAlfred ? 'Token provided via Workflow Configuration' : 'Token is stored in system keychain')\n : (inAlfred ? 'No token set in Workflow Configuration' : 'No token found in system keychain'),\n icon: this.getIcon(status.hasToken),\n arg: status.hasToken ? 'token:present' : 'token:not-present'\n });\n\n if (status.hasToken) {\n // Add overall validity item\n items.push({\n title: `Valid: ${status.isValid ? 'Yes' : 'No'}`,\n subtitle: status.isValid ? 'Token is valid for all required APIs' : 'Token has limited access',\n icon: this.getIcon(status.isValid),\n arg: status.isValid ? 'token:valid' : 'token:invalid'\n });\n\n if (status.validation.canListOrganizations) {\n // Add organization status items\n Object.entries(status.validation.organizations).forEach(([org, orgStatus]) => {\n const isValid = orgStatus.graphql && orgStatus.builds && orgStatus.organizations;\n const invalidApis = [];\n if (!orgStatus.graphql) invalidApis.push('GraphQL');\n if (!orgStatus.builds) invalidApis.push('Builds');\n if (!orgStatus.organizations) invalidApis.push('Organizations');\n \n items.push({\n title: `Organization: ${org}`,\n subtitle: isValid \n ? 'Full access to all APIs'\n : `Limited access: ${invalidApis.join(', ')}`,\n icon: this.getIcon(isValid),\n arg: isValid ? `org:${org}:valid` : `org:${org}:invalid`\n });\n });\n } else {\n items.push({\n title: 'Cannot list organizations',\n subtitle: 'Token may be invalid or lacks necessary permissions',\n icon: this.getIcon(false),\n arg: 'token:no-org-access'\n });\n }\n }\n\n return items;\n }\n\n private formatTokenValidationStatusAsItems(validation: TokenValidationStatus): AlfredItem[] {\n const items: AlfredItem[] = [];\n\n if (!validation.canListOrganizations) {\n items.push({\n title: 'Cannot list organizations',\n subtitle: 'Token may be invalid or lacks necessary permissions',\n icon: this.getIcon(false),\n arg: 'token:no-org-access'\n });\n return items;\n }\n\n // Add organization status items\n Object.entries(validation.organizations).forEach(([org, orgStatus]) => {\n const isValid = orgStatus.graphql && orgStatus.builds && orgStatus.organizations;\n const invalidApis = [];\n if (!orgStatus.graphql) invalidApis.push('GraphQL');\n if (!orgStatus.builds) invalidApis.push('Builds');\n if (!orgStatus.organizations) invalidApis.push('Organizations');\n \n items.push({\n title: `Organization: ${org}`,\n subtitle: isValid \n ? 'Full access to all APIs'\n : `Limited access: ${invalidApis.join(', ')}`,\n icon: this.getIcon(isValid),\n arg: isValid ? `org:${org}:valid` : `org:${org}:invalid`\n });\n });\n\n return items;\n }\n} "]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseTokenFormatter } from './Formatter.js';
|
|
2
|
+
import { SEMANTIC_COLORS, formatError as themeFormatError, formatTips, TipStyle } from '../../ui/theme.js';
|
|
2
3
|
/**
|
|
3
4
|
* Plain text formatter for tokens
|
|
4
5
|
*/
|
|
@@ -12,21 +13,42 @@ export class PlainTextFormatter extends BaseTokenFormatter {
|
|
|
12
13
|
*/
|
|
13
14
|
formatTokenStatus(status) {
|
|
14
15
|
const lines = [];
|
|
15
|
-
|
|
16
|
+
// Header with visual emphasis
|
|
17
|
+
lines.push(SEMANTIC_COLORS.heading('Token Configuration'));
|
|
18
|
+
lines.push('');
|
|
19
|
+
// Token presence with semantic coloring - aligned labels
|
|
20
|
+
if (status.hasToken) {
|
|
21
|
+
if (status.isValid) {
|
|
22
|
+
lines.push(`${SEMANTIC_COLORS.label('Status:')} ${SEMANTIC_COLORS.success('✓ Valid token')}`);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
lines.push(`${SEMANTIC_COLORS.label('Status:')} ${SEMANTIC_COLORS.error('✖ Invalid token')}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
lines.push(`${SEMANTIC_COLORS.label('Status:')} ${SEMANTIC_COLORS.muted('No token configured')}`);
|
|
30
|
+
}
|
|
16
31
|
if (status.hasToken) {
|
|
17
|
-
lines.push(`Valid: ${status.isValid ? 'Yes' : 'No'}`);
|
|
18
32
|
if (status.validation.canListOrganizations) {
|
|
19
33
|
const validOrgs = Object.entries(status.validation.organizations)
|
|
20
34
|
.filter(([_, status]) => status.graphql && status.builds && status.organizations)
|
|
21
35
|
.map(([org]) => org);
|
|
22
|
-
if (validOrgs.length > 0) {
|
|
23
|
-
lines.push('Valid Organizations:');
|
|
24
|
-
validOrgs.forEach(org => lines.push(` - ${org}`));
|
|
25
|
-
}
|
|
26
36
|
const invalidOrgs = Object.entries(status.validation.organizations)
|
|
27
37
|
.filter(([_, status]) => !status.graphql || !status.builds || !status.organizations);
|
|
38
|
+
// Display access info with aligned labels
|
|
39
|
+
if (validOrgs.length > 0 || invalidOrgs.length > 0) {
|
|
40
|
+
const totalOrgs = validOrgs.length + invalidOrgs.length;
|
|
41
|
+
const accessLabel = totalOrgs === 1 ? 'Organization' : 'Organizations';
|
|
42
|
+
lines.push(`${SEMANTIC_COLORS.label('Access:')} ${SEMANTIC_COLORS.count(totalOrgs.toString())} ${accessLabel.toLowerCase()}`);
|
|
43
|
+
}
|
|
44
|
+
if (validOrgs.length > 0) {
|
|
45
|
+
lines.push('');
|
|
46
|
+
lines.push(SEMANTIC_COLORS.label('Valid Organizations:'));
|
|
47
|
+
validOrgs.forEach(org => lines.push(` ${SEMANTIC_COLORS.success('✓')} ${org}`));
|
|
48
|
+
}
|
|
28
49
|
if (invalidOrgs.length > 0) {
|
|
29
|
-
lines.push('
|
|
50
|
+
lines.push('');
|
|
51
|
+
lines.push(SEMANTIC_COLORS.warning('Limited Access:'));
|
|
30
52
|
invalidOrgs.forEach(([org, status]) => {
|
|
31
53
|
const invalidApis = [];
|
|
32
54
|
if (!status.graphql)
|
|
@@ -35,14 +57,23 @@ export class PlainTextFormatter extends BaseTokenFormatter {
|
|
|
35
57
|
invalidApis.push('Builds');
|
|
36
58
|
if (!status.organizations)
|
|
37
59
|
invalidApis.push('Organizations');
|
|
38
|
-
lines.push(`
|
|
60
|
+
lines.push(` ${SEMANTIC_COLORS.warning('⚠')} ${org} ${SEMANTIC_COLORS.dim(`(missing: ${invalidApis.join(', ')})`)} `);
|
|
39
61
|
});
|
|
40
62
|
}
|
|
41
63
|
}
|
|
42
64
|
else {
|
|
43
|
-
lines.push('Cannot list organizations
|
|
65
|
+
lines.push(`${SEMANTIC_COLORS.label('Access:')} ${SEMANTIC_COLORS.error('Cannot list organizations')}`);
|
|
44
66
|
}
|
|
45
67
|
}
|
|
68
|
+
else {
|
|
69
|
+
// Help for users without a token
|
|
70
|
+
lines.push('');
|
|
71
|
+
const actionTips = [
|
|
72
|
+
'Run: bktide token --store',
|
|
73
|
+
'Or set: BUILDKITE_API_TOKEN environment variable'
|
|
74
|
+
];
|
|
75
|
+
lines.push(formatTips(actionTips, TipStyle.ACTIONS));
|
|
76
|
+
}
|
|
46
77
|
return lines.join('\n');
|
|
47
78
|
}
|
|
48
79
|
/**
|
|
@@ -53,10 +84,10 @@ export class PlainTextFormatter extends BaseTokenFormatter {
|
|
|
53
84
|
*/
|
|
54
85
|
formatTokenStorageResult(success) {
|
|
55
86
|
if (success) {
|
|
56
|
-
return 'Token
|
|
87
|
+
return `${SEMANTIC_COLORS.success('✓')} Token stored in system keychain`;
|
|
57
88
|
}
|
|
58
89
|
else {
|
|
59
|
-
return 'Failed to store token
|
|
90
|
+
return `${SEMANTIC_COLORS.error('✖')} Failed to store token`;
|
|
60
91
|
}
|
|
61
92
|
}
|
|
62
93
|
/**
|
|
@@ -68,13 +99,13 @@ export class PlainTextFormatter extends BaseTokenFormatter {
|
|
|
68
99
|
*/
|
|
69
100
|
formatTokenResetResult(success, hadToken) {
|
|
70
101
|
if (!hadToken) {
|
|
71
|
-
return 'No token found in system keychain'
|
|
102
|
+
return `${SEMANTIC_COLORS.muted('No token found in system keychain')}`;
|
|
72
103
|
}
|
|
73
104
|
if (success) {
|
|
74
|
-
return 'Token
|
|
105
|
+
return `${SEMANTIC_COLORS.success('✓')} Token removed from system keychain`;
|
|
75
106
|
}
|
|
76
107
|
else {
|
|
77
|
-
return 'Failed to delete token
|
|
108
|
+
return `${SEMANTIC_COLORS.error('✖')} Failed to delete token`;
|
|
78
109
|
}
|
|
79
110
|
}
|
|
80
111
|
/**
|
|
@@ -148,10 +179,17 @@ export class PlainTextFormatter extends BaseTokenFormatter {
|
|
|
148
179
|
*/
|
|
149
180
|
formatError(operation, error) {
|
|
150
181
|
const errors = Array.isArray(error) ? error : [error];
|
|
151
|
-
|
|
152
|
-
const errorMessage =
|
|
153
|
-
return
|
|
154
|
-
})
|
|
182
|
+
const errorMessages = errors.map(err => {
|
|
183
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
184
|
+
return errorMessage;
|
|
185
|
+
});
|
|
186
|
+
const suggestions = [];
|
|
187
|
+
if (operation === 'storing' || operation === 'validating') {
|
|
188
|
+
suggestions.push('Check your Buildkite API token permissions');
|
|
189
|
+
suggestions.push('Get a new token at: https://buildkite.com/user/api-access-tokens');
|
|
190
|
+
}
|
|
191
|
+
const errorText = `Error ${operation} token: ${errorMessages.join(', ')}`;
|
|
192
|
+
return themeFormatError(errorText, { suggestions });
|
|
155
193
|
}
|
|
156
194
|
/**
|
|
157
195
|
* Format authentication error message(s) in plain text
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlainTextFormatter.js","sourceRoot":"/","sources":["formatters/token/PlainTextFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,gBAAgB,CAAC;AAGpE;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IACxD,IAAI,GAAG,OAAO,CAAC;IAEf;;;;;OAKG;IACH,iBAAiB,CAAC,MAAmB;QACnC,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,iBAAiB,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC;QAE3E,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,KAAK,CAAC,IAAI,CAAC,UAAU,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAEtD,IAAI,MAAM,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC;gBAC3C,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC;qBAC9D,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,aAAa,CAAC;qBAChF,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;gBAEvB,IAAI,SAAS,CAAC,MAA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C,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACtD,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACxB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO,wBAAwB,SAAS,WAAW,YAAY,qDAAqD,CAAC;QACvH,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACH,YAAY,CACV,SAAiB,EACjB,MAAiB;QAEjB,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACxB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO,SAAS,SAAS,WAAW,YAAY,EAAE,CAAC;QACrD,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { BaseTokenFormatter, TokenFormatter } from './Formatter.js';\nimport { TokenStatus, TokenValidationStatus } from '../../types/credentials.js';\n \n/**\n * Plain text formatter for tokens\n */\nexport class PlainTextFormatter extends BaseTokenFormatter implements TokenFormatter {\n name = 'plain';\n\n /**\n * Format token status information in plain text\n * \n * @param status The token status information\n * @returns Formatted token status message\n */\n formatTokenStatus(status: TokenStatus): string {\n const lines: string[] = [];\n lines.push(`Token Status: ${status.hasToken ? 'Present' : 'Not Present'}`);\n \n if (status.hasToken) {\n lines.push(`Valid: ${status.isValid ? 'Yes' : 'No'}`);\n \n if (status.validation.canListOrganizations) {\n const validOrgs = Object.entries(status.validation.organizations)\n .filter(([_, status]) => status.graphql && status.builds && status.organizations)\n .map(([org]) => org);\n \n if (validOrgs.length > 0) {\n lines.push('Valid Organizations:');\n validOrgs.forEach(org => lines.push(` - ${org}`));\n }\n\n const invalidOrgs = Object.entries(status.validation.organizations)\n .filter(([_, status]) => !status.graphql || !status.builds || !status.organizations);\n \n if (invalidOrgs.length > 0) {\n lines.push('Organizations with Limited Access:');\n invalidOrgs.forEach(([org, status]) => {\n const invalidApis = [];\n if (!status.graphql) invalidApis.push('GraphQL');\n if (!status.builds) invalidApis.push('Builds');\n if (!status.organizations) invalidApis.push('Organizations');\n lines.push(` - ${org} (${invalidApis.join(', ')})`);\n });\n }\n } else {\n lines.push('Cannot list organizations - token may be invalid');\n }\n }\n \n return lines.join('\\n');\n }\n\n /**\n * Format token storage result in plain text\n * \n * @param success Whether the token was successfully stored\n * @returns Formatted token storage result message\n */\n formatTokenStorageResult(success: boolean): string {\n if (success) {\n return 'Token successfully stored in system keychain';\n } else {\n return 'Failed to store token';\n }\n }\n\n /**\n * Format token reset result in plain text\n * \n * @param success Whether the token was successfully reset\n * @param hadToken Whether there was a token before reset\n * @returns Formatted token reset result message\n */\n formatTokenResetResult(success: boolean, hadToken: boolean): string {\n if (!hadToken) {\n return 'No token found in system keychain';\n }\n\n if (success) {\n return 'Token successfully deleted from system keychain';\n } else {\n return 'Failed to delete token';\n }\n }\n\n /**\n * Format token validation error in plain text\n * \n * @param validation The validation status for each API\n * @returns Formatted token validation error message\n */\n formatTokenValidationError(\n validation: TokenValidationStatus\n ): string {\n if (!validation.canListOrganizations) {\n return 'Token is invalid or does not have access to list organizations';\n }\n\n const invalidOrgs = Object.entries(validation.organizations)\n .filter(([_, status]) => !status.graphql || !status.builds || !status.organizations)\n .map(([org, status]) => {\n const invalidApis = [];\n if (!status.graphql) invalidApis.push('GraphQL');\n if (!status.builds) invalidApis.push('Builds');\n if (!status.organizations) invalidApis.push('Organizations');\n return `${org} (${invalidApis.join(', ')})`;\n });\n\n if (invalidOrgs.length === 0) {\n return 'Token is valid for all organizations';\n }\n\n return `Token has limited access in some organizations: ${invalidOrgs.join(', ')}`;\n }\n\n /**\n * Format token validation status in plain text\n * \n * @param validation The validation status for each API\n * @returns Formatted token validation status message\n */\n formatTokenValidationStatus(validation: TokenValidationStatus): string {\n if (!validation.canListOrganizations) {\n return 'Token is invalid or does not have access to list organizations';\n }\n\n const lines: string[] = [];\n const validOrgs = Object.entries(validation.organizations)\n .filter(([_, status]) => status.graphql && status.builds && status.organizations)\n .map(([org]) => org);\n \n if (validOrgs.length > 0) {\n lines.push('Valid Organizations:');\n validOrgs.forEach(org => lines.push(` - ${org}`));\n }\n\n const invalidOrgs = Object.entries(validation.organizations)\n .filter(([_, status]) => !status.graphql || !status.builds || !status.organizations);\n \n if (invalidOrgs.length > 0) {\n lines.push('Organizations with Limited Access:');\n invalidOrgs.forEach(([org, status]) => {\n const invalidApis = [];\n if (!status.graphql) invalidApis.push('GraphQL');\n if (!status.builds) invalidApis.push('Builds');\n if (!status.organizations) invalidApis.push('Organizations');\n lines.push(` - ${org} (${invalidApis.join(', ')})`);\n });\n }\n\n return lines.join('\\n');\n }\n\n /**\n * Format error message(s) in plain text\n * \n * @param operation The operation that failed (e.g., 'storing', 'resetting', 'validating')\n * @param error The error that occurred, or an array of errors\n * @returns Formatted error message(s)\n */\n formatError(\n operation: string,\n error: unknown | unknown[]\n ): string {\n const errors = Array.isArray(error) ? error : [error];\n return errors.map(error => {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return `Error ${operation} token: ${errorMessage}`;\n }).join('\\n');\n }\n\n /**\n * Format authentication error message(s) in plain text\n * \n * @param operation The authentication operation that failed (e.g., 'storing', 'validating')\n * @param error The authentication error that occurred, or an array of errors\n * @returns Formatted authentication error message(s)\n */\n formatAuthErrors(\n operation: string,\n error: unknown | unknown[]\n ): string {\n const errors = Array.isArray(error) ? error : [error];\n return errors.map(error => {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return `Authentication error ${operation} token: ${errorMessage}\\nPlease check your token permissions and try again`;\n }).join('\\n\\n');\n }\n\n /**\n * Format multiple error messages in plain text\n * \n * @param operation The operation that failed (e.g., 'storing', 'resetting', 'validating')\n * @param errors Array of errors that occurred\n * @returns Formatted error messages\n */\n formatErrors(\n operation: string,\n errors: unknown[]\n ): string {\n return errors.map(error => {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return `Error ${operation} token: ${errorMessage}`;\n }).join('\\n');\n }\n} "]}
|
|
1
|
+
{"version":3,"file":"PlainTextFormatter.js","sourceRoot":"/","sources":["formatters/token/PlainTextFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,WAAW,IAAI,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE3G;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IACxD,IAAI,GAAG,OAAO,CAAC;IAEf;;;;;OAKG;IACH,iBAAiB,CAAC,MAAmB;QACnC,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,8BAA8B;QAC9B,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEf,yDAAyD;QACzD,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,KAAK,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,eAAe,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;YACjG,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,eAAe,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;YACjG,CAAC;QACH,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,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AAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACH,YAAY,CACV,SAAiB,EACjB,MAAiB;QAEjB,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACxB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO,SAAS,SAAS,WAAW,YAAY,EAAE,CAAC;QACrD,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { BaseTokenFormatter, TokenFormatter } from './Formatter.js';\nimport { TokenStatus, TokenValidationStatus } from '../../types/credentials.js';\nimport { SEMANTIC_COLORS, formatError as themeFormatError, formatTips, TipStyle } from '../../ui/theme.js';\n \n/**\n * Plain text formatter for tokens\n */\nexport class PlainTextFormatter extends BaseTokenFormatter implements TokenFormatter {\n name = 'plain';\n\n /**\n * Format token status information in plain text\n * \n * @param status The token status information\n * @returns Formatted token status message\n */\n formatTokenStatus(status: TokenStatus): string {\n const lines: string[] = [];\n \n // Header with visual emphasis\n lines.push(SEMANTIC_COLORS.heading('Token Configuration'));\n lines.push('');\n \n // Token presence with semantic coloring - aligned labels\n if (status.hasToken) {\n if (status.isValid) {\n lines.push(`${SEMANTIC_COLORS.label('Status:')} ${SEMANTIC_COLORS.success('✓ Valid token')}`);\n } else {\n lines.push(`${SEMANTIC_COLORS.label('Status:')} ${SEMANTIC_COLORS.error('✖ Invalid token')}`);\n }\n } else {\n lines.push(`${SEMANTIC_COLORS.label('Status:')} ${SEMANTIC_COLORS.muted('No token configured')}`);\n }\n \n if (status.hasToken) {\n if (status.validation.canListOrganizations) {\n const validOrgs = Object.entries(status.validation.organizations)\n .filter(([_, status]) => status.graphql && status.builds && status.organizations)\n .map(([org]) => org);\n \n const invalidOrgs = Object.entries(status.validation.organizations)\n .filter(([_, status]) => !status.graphql || !status.builds || !status.organizations);\n \n // Display access info with aligned labels\n if (validOrgs.length > 0 || invalidOrgs.length > 0) {\n const totalOrgs = validOrgs.length + invalidOrgs.length;\n const accessLabel = totalOrgs === 1 ? 'Organization' : 'Organizations';\n lines.push(`${SEMANTIC_COLORS.label('Access:')} ${SEMANTIC_COLORS.count(totalOrgs.toString())} ${accessLabel.toLowerCase()}`);\n }\n \n if (validOrgs.length > 0) {\n lines.push('');\n lines.push(SEMANTIC_COLORS.label('Valid Organizations:'));\n validOrgs.forEach(org => lines.push(` ${SEMANTIC_COLORS.success('✓')} ${org}`));\n }\n\n if (invalidOrgs.length > 0) {\n lines.push('');\n lines.push(SEMANTIC_COLORS.warning('Limited Access:'));\n invalidOrgs.forEach(([org, status]) => {\n const invalidApis = [];\n if (!status.graphql) invalidApis.push('GraphQL');\n if (!status.builds) invalidApis.push('Builds');\n if (!status.organizations) invalidApis.push('Organizations');\n lines.push(` ${SEMANTIC_COLORS.warning('⚠')} ${org} ${SEMANTIC_COLORS.dim(`(missing: ${invalidApis.join(', ')})`)} `);\n });\n }\n } else {\n lines.push(`${SEMANTIC_COLORS.label('Access:')} ${SEMANTIC_COLORS.error('Cannot list organizations')}`);\n }\n } else {\n // Help for users without a token\n lines.push('');\n const actionTips = [\n 'Run: bktide token --store',\n 'Or set: BUILDKITE_API_TOKEN environment variable'\n ];\n lines.push(formatTips(actionTips, TipStyle.ACTIONS));\n }\n \n return lines.join('\\n');\n }\n\n /**\n * Format token storage result in plain text\n * \n * @param success Whether the token was successfully stored\n * @returns Formatted token storage result message\n */\n formatTokenStorageResult(success: boolean): string {\n if (success) {\n return `${SEMANTIC_COLORS.success('✓')} Token stored in system keychain`;\n } else {\n return `${SEMANTIC_COLORS.error('✖')} Failed to store token`;\n }\n }\n\n /**\n * Format token reset result in plain text\n * \n * @param success Whether the token was successfully reset\n * @param hadToken Whether there was a token before reset\n * @returns Formatted token reset result message\n */\n formatTokenResetResult(success: boolean, hadToken: boolean): string {\n if (!hadToken) {\n return `${SEMANTIC_COLORS.muted('No token found in system keychain')}`;\n }\n\n if (success) {\n return `${SEMANTIC_COLORS.success('✓')} Token removed from system keychain`;\n } else {\n return `${SEMANTIC_COLORS.error('✖')} Failed to delete token`;\n }\n }\n\n /**\n * Format token validation error in plain text\n * \n * @param validation The validation status for each API\n * @returns Formatted token validation error message\n */\n formatTokenValidationError(\n validation: TokenValidationStatus\n ): string {\n if (!validation.canListOrganizations) {\n return 'Token is invalid or does not have access to list organizations';\n }\n\n const invalidOrgs = Object.entries(validation.organizations)\n .filter(([_, status]) => !status.graphql || !status.builds || !status.organizations)\n .map(([org, status]) => {\n const invalidApis = [];\n if (!status.graphql) invalidApis.push('GraphQL');\n if (!status.builds) invalidApis.push('Builds');\n if (!status.organizations) invalidApis.push('Organizations');\n return `${org} (${invalidApis.join(', ')})`;\n });\n\n if (invalidOrgs.length === 0) {\n return 'Token is valid for all organizations';\n }\n\n return `Token has limited access in some organizations: ${invalidOrgs.join(', ')}`;\n }\n\n /**\n * Format token validation status in plain text\n * \n * @param validation The validation status for each API\n * @returns Formatted token validation status message\n */\n formatTokenValidationStatus(validation: TokenValidationStatus): string {\n if (!validation.canListOrganizations) {\n return 'Token is invalid or does not have access to list organizations';\n }\n\n const lines: string[] = [];\n const validOrgs = Object.entries(validation.organizations)\n .filter(([_, status]) => status.graphql && status.builds && status.organizations)\n .map(([org]) => org);\n \n if (validOrgs.length > 0) {\n lines.push('Valid Organizations:');\n validOrgs.forEach(org => lines.push(` - ${org}`));\n }\n\n const invalidOrgs = Object.entries(validation.organizations)\n .filter(([_, status]) => !status.graphql || !status.builds || !status.organizations);\n \n if (invalidOrgs.length > 0) {\n lines.push('Organizations with Limited Access:');\n invalidOrgs.forEach(([org, status]) => {\n const invalidApis = [];\n if (!status.graphql) invalidApis.push('GraphQL');\n if (!status.builds) invalidApis.push('Builds');\n if (!status.organizations) invalidApis.push('Organizations');\n lines.push(` - ${org} (${invalidApis.join(', ')})`);\n });\n }\n\n return lines.join('\\n');\n }\n\n /**\n * Format error message(s) in plain text\n * \n * @param operation The operation that failed (e.g., 'storing', 'resetting', 'validating')\n * @param error The error that occurred, or an array of errors\n * @returns Formatted error message(s)\n */\n formatError(\n operation: string,\n error: unknown | unknown[]\n ): string {\n const errors = Array.isArray(error) ? error : [error];\n const errorMessages = errors.map(err => {\n const errorMessage = err instanceof Error ? err.message : String(err);\n return errorMessage;\n });\n \n const suggestions = [];\n if (operation === 'storing' || operation === 'validating') {\n suggestions.push('Check your Buildkite API token permissions');\n suggestions.push('Get a new token at: https://buildkite.com/user/api-access-tokens');\n }\n \n const errorText = `Error ${operation} token: ${errorMessages.join(', ')}`;\n return themeFormatError(errorText, { suggestions });\n }\n\n /**\n * Format authentication error message(s) in plain text\n * \n * @param operation The authentication operation that failed (e.g., 'storing', 'validating')\n * @param error The authentication error that occurred, or an array of errors\n * @returns Formatted authentication error message(s)\n */\n formatAuthErrors(\n operation: string,\n error: unknown | unknown[]\n ): string {\n const errors = Array.isArray(error) ? error : [error];\n return errors.map(error => {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return `Authentication error ${operation} token: ${errorMessage}\\nPlease check your token permissions and try again`;\n }).join('\\n\\n');\n }\n\n /**\n * Format multiple error messages in plain text\n * \n * @param operation The operation that failed (e.g., 'storing', 'resetting', 'validating')\n * @param errors Array of errors that occurred\n * @returns Formatted error messages\n */\n formatErrors(\n operation: string,\n errors: unknown[]\n ): string {\n return errors.map(error => {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return `Error ${operation} token: ${errorMessage}`;\n }).join('\\n');\n }\n} "]}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { BaseFormatter } from './Formatter.js';
|
|
2
|
+
import { SEMANTIC_COLORS, formatEmptyState } from '../../ui/theme.js';
|
|
2
3
|
export class PlainTextFormatter extends BaseFormatter {
|
|
3
4
|
name = 'plain-text';
|
|
4
5
|
formatViewer(viewerData, _options) {
|
|
5
6
|
if (!viewerData?.viewer) {
|
|
6
|
-
return 'No viewer data found
|
|
7
|
+
return formatEmptyState('No viewer data found', ['Check your API token is valid', 'Run "bktide token --check" to verify']);
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
const lines = [];
|
|
9
10
|
if (viewerData.viewer.user) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
lines.push(`${SEMANTIC_COLORS.label('Name:')} ${viewerData.viewer.user.name || SEMANTIC_COLORS.muted('(not set)')}`);
|
|
12
|
+
lines.push(`${SEMANTIC_COLORS.label('Email:')} ${viewerData.viewer.user.email || SEMANTIC_COLORS.muted('(not set)')}`);
|
|
13
|
+
lines.push(`${SEMANTIC_COLORS.label('ID:')} ${SEMANTIC_COLORS.identifier(viewerData.viewer.user.id || '(unknown)')}`);
|
|
13
14
|
}
|
|
14
15
|
else {
|
|
15
|
-
|
|
16
|
+
return formatEmptyState('No user data found', ['Your token may not have the required permissions']);
|
|
16
17
|
}
|
|
17
|
-
return
|
|
18
|
+
return lines.join('\n');
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=PlainTextFormatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlainTextFormatter.js","sourceRoot":"/","sources":["formatters/viewer/PlainTextFormatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"PlainTextFormatter.js","sourceRoot":"/","sources":["formatters/viewer/PlainTextFormatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,OAAO,kBAAmB,SAAQ,aAAa;IACnD,IAAI,GAAG,YAAY,CAAC;IAEpB,YAAY,CAAC,UAAsB,EAAE,QAA2B;QAC9D,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;YACxB,OAAO,gBAAgB,CACrB,sBAAsB,EACtB,CAAC,+BAA+B,EAAE,sCAAsC,CAAC,CAC1E,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACtH,KAAK,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACvH,KAAK,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;QAC3H,CAAC;aAAM,CAAC;YACN,OAAO,gBAAgB,CACrB,oBAAoB,EACpB,CAAC,kDAAkD,CAAC,CACrD,CAAC;QACJ,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF","sourcesContent":["import { FormatterOptions } from '../BaseFormatter.js';\nimport { BaseFormatter } from './Formatter.js';\nimport { ViewerData } from '../../types/index.js';\nimport { SEMANTIC_COLORS, formatEmptyState } from '../../ui/theme.js';\n\nexport class PlainTextFormatter extends BaseFormatter {\n name = 'plain-text';\n \n formatViewer(viewerData: ViewerData, _options?: FormatterOptions): string {\n if (!viewerData?.viewer) {\n return formatEmptyState(\n 'No viewer data found',\n ['Check your API token is valid', 'Run \"bktide token --check\" to verify']\n );\n }\n\n const lines: string[] = [];\n \n if (viewerData.viewer.user) {\n lines.push(`${SEMANTIC_COLORS.label('Name:')} ${viewerData.viewer.user.name || SEMANTIC_COLORS.muted('(not set)')}`);\n lines.push(`${SEMANTIC_COLORS.label('Email:')} ${viewerData.viewer.user.email || SEMANTIC_COLORS.muted('(not set)')}`);\n lines.push(`${SEMANTIC_COLORS.label('ID:')} ${SEMANTIC_COLORS.identifier(viewerData.viewer.user.id || '(unknown)')}`);\n } else {\n return formatEmptyState(\n 'No user data found',\n ['Your token may not have the required permissions']\n );\n }\n \n return lines.join('\\n');\n }\n} "]}
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,11 @@ 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 } from './commands/index.js';
|
|
6
|
+
import { BaseCommand, ShowViewer, ListOrganizations, ListBuilds, ListPipelines, ManageToken, ListAnnotations, GenerateCompletions } 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';
|
|
10
|
+
import { WidthAwareHelp } from './ui/help.js';
|
|
10
11
|
// Set a global error handler for uncaught exceptions
|
|
11
12
|
const uncaughtExceptionHandler = (err) => {
|
|
12
13
|
// Remove any existing handlers to avoid duplicates
|
|
@@ -49,6 +50,8 @@ const createCommandHandler = (CommandClass) => {
|
|
|
49
50
|
token: options.token,
|
|
50
51
|
debug: options.debug,
|
|
51
52
|
format: options.format,
|
|
53
|
+
quiet: options.quiet,
|
|
54
|
+
tips: options.tips,
|
|
52
55
|
});
|
|
53
56
|
// Pass command-specific options if available
|
|
54
57
|
const commandName = this.name();
|
|
@@ -98,19 +101,27 @@ function resolveAppVersion() {
|
|
|
98
101
|
// Last resort
|
|
99
102
|
return '0.0.0';
|
|
100
103
|
}
|
|
104
|
+
// Create custom help instance
|
|
105
|
+
const customHelp = new WidthAwareHelp();
|
|
101
106
|
program
|
|
102
107
|
.name('bktide')
|
|
103
108
|
.description('Buildkite CLI tool')
|
|
104
109
|
.version(resolveAppVersion())
|
|
105
|
-
.configureHelp(
|
|
110
|
+
.configureHelp(customHelp)
|
|
111
|
+
.showSuggestionAfterError()
|
|
106
112
|
.option('--log-level <level>', 'Set logging level (trace, debug, info, warn, error, fatal)', 'info')
|
|
107
113
|
.option('-d, --debug', 'Show debug information for errors')
|
|
108
114
|
.option('--no-cache', 'Disable caching of API responses')
|
|
109
115
|
.option('--cache-ttl <milliseconds>', 'Set cache time-to-live in milliseconds', parseInt)
|
|
110
116
|
.option('--clear-cache', 'Clear all cached data before executing command')
|
|
111
|
-
.option('-t, --token <token>', 'Buildkite API token (or
|
|
117
|
+
.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)
|
|
112
118
|
.option('--save-token', 'Save the token to system keychain for future use')
|
|
113
|
-
.option('-f, --format <format>', 'Output format for results and errors (plain, json, alfred)', 'plain')
|
|
119
|
+
.option('-f, --format <format>', 'Output format for results and errors (plain, json, alfred)', 'plain')
|
|
120
|
+
.option('--color <mode>', 'Color output: auto|always|never', 'auto')
|
|
121
|
+
.option('-q, --quiet', 'Suppress non-error output (plain format only)')
|
|
122
|
+
.option('--tips', 'Show helpful tips and suggestions')
|
|
123
|
+
.option('--no-tips', 'Hide helpful tips and suggestions')
|
|
124
|
+
.option('--ascii', 'Use ASCII symbols instead of Unicode');
|
|
114
125
|
// Add hooks for handling options
|
|
115
126
|
program
|
|
116
127
|
.hook('preAction', (_thisCommand, actionCommand) => {
|
|
@@ -124,9 +135,29 @@ program
|
|
|
124
135
|
if (mergedOptions.format) {
|
|
125
136
|
setErrorFormat(mergedOptions.format);
|
|
126
137
|
}
|
|
138
|
+
// Apply color mode
|
|
139
|
+
if (mergedOptions.color) {
|
|
140
|
+
const mode = String(mergedOptions.color).toLowerCase();
|
|
141
|
+
// Respect NO_COLOR when mode is never; clear when always
|
|
142
|
+
if (mode === 'never') {
|
|
143
|
+
process.env.NO_COLOR = '1';
|
|
144
|
+
}
|
|
145
|
+
else if (mode === 'always') {
|
|
146
|
+
// Explicitly enable color by unsetting NO_COLOR; downstream code should still TTY-check
|
|
147
|
+
if (process.env.NO_COLOR) {
|
|
148
|
+
delete process.env.NO_COLOR;
|
|
149
|
+
}
|
|
150
|
+
process.env.BKTIDE_COLOR_MODE = 'always';
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// auto
|
|
154
|
+
process.env.BKTIDE_COLOR_MODE = 'auto';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
127
157
|
if (mergedOptions.cacheTtl && (isNaN(mergedOptions.cacheTtl) || mergedOptions.cacheTtl <= 0)) {
|
|
128
158
|
logger.error('cache-ttl must be a positive number');
|
|
129
|
-
process.
|
|
159
|
+
process.exitCode = 1;
|
|
160
|
+
return;
|
|
130
161
|
}
|
|
131
162
|
if (mergedOptions.cache === false && mergedOptions.cacheTtl) {
|
|
132
163
|
logger.warn('--no-cache and --cache-ttl used together. Cache will be disabled regardless of TTL setting.');
|
|
@@ -134,7 +165,8 @@ program
|
|
|
134
165
|
// Validate count options
|
|
135
166
|
if (mergedOptions.count && (isNaN(parseInt(mergedOptions.count)) || parseInt(mergedOptions.count) <= 0)) {
|
|
136
167
|
logger.error('count must be a positive number');
|
|
137
|
-
process.
|
|
168
|
+
process.exitCode = 1;
|
|
169
|
+
return;
|
|
138
170
|
}
|
|
139
171
|
cmd.mergedOptions = mergedOptions;
|
|
140
172
|
const commandName = cmd.name();
|
|
@@ -228,6 +260,15 @@ program
|
|
|
228
260
|
.argument('<build>', 'Build reference (org/pipeline/number or @https://buildkite.com/org/pipeline/builds/number)')
|
|
229
261
|
.option('--context <context>', 'Filter annotations by context (e.g., rspec, build-resources)')
|
|
230
262
|
.action(createCommandHandler(ListAnnotations));
|
|
263
|
+
// Add completions command
|
|
264
|
+
program
|
|
265
|
+
.command('completions [shell]')
|
|
266
|
+
.description('Generate shell completions')
|
|
267
|
+
.action(async (shell) => {
|
|
268
|
+
const handler = new GenerateCompletions();
|
|
269
|
+
const exitCode = await handler.execute({ shell, quiet: program.opts().quiet, debug: program.opts().debug });
|
|
270
|
+
process.exitCode = exitCode;
|
|
271
|
+
});
|
|
231
272
|
program
|
|
232
273
|
.command('boom')
|
|
233
274
|
.description('Test error handling')
|
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,EAChB,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;AAE3D,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;Y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AO,CAAC,CAAC;IACrB,MAAM,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;AACtD,CAAC;KAAM,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC5B,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,CAAC,KAAK,CAAC,oBAAoB,OAAO,CAAC,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} 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';\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 });\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\nprogram\n .name('bktide')\n .description('Buildkite CLI tool')\n .version(resolveAppVersion())\n .configureHelp({ showGlobalOptions: true })\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 (or set BK_TOKEN env var)', 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\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 if (mergedOptions.cacheTtl && (isNaN(mergedOptions.cacheTtl) || mergedOptions.cacheTtl <= 0)) {\n logger.error('cache-ttl must be a positive number');\n process.exit(1);\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.exit(1);\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 \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\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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AAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,CAAC,KAAK,CAAC,oBAAoB,OAAO,CAAC,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} 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 \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 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'); "]}
|