File tree Expand file tree Collapse file tree 10 files changed +30
-19
lines changed
Expand file tree Collapse file tree 10 files changed +30
-19
lines changed Original file line number Diff line number Diff line change 88import { buildCommand } from "@stricli/core" ;
99import type { SentryContext } from "../context.js" ;
1010import { rawApiRequest } from "../lib/api-client.js" ;
11+ import type { Writer } from "../types/index.js" ;
1112
1213type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" ;
1314
@@ -124,7 +125,7 @@ function parseHeaders(headers: string[]): Record<string, string> {
124125 * Write response headers to stdout
125126 */
126127function writeResponseHeaders (
127- stdout : NodeJS . WriteStream ,
128+ stdout : Writer ,
128129 status : number ,
129130 headers : Headers
130131) : void {
@@ -138,7 +139,7 @@ function writeResponseHeaders(
138139/**
139140 * Write response body to stdout
140141 */
141- function writeResponseBody ( stdout : NodeJS . WriteStream , body : unknown ) : void {
142+ function writeResponseBody ( stdout : Writer , body : unknown ) : void {
142143 if ( body === null || body === undefined ) {
143144 return ;
144145 }
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import {
1515 readConfig ,
1616} from "../../lib/config.js" ;
1717import { formatExpiration , maskToken } from "../../lib/formatters/human.js" ;
18- import type { SentryConfig } from "../../types/index.js" ;
18+ import type { SentryConfig , Writer } from "../../types/index.js" ;
1919
2020type StatusFlags = {
2121 readonly showToken : boolean ;
@@ -25,7 +25,7 @@ type StatusFlags = {
2525 * Write token information
2626 */
2727function writeTokenInfo (
28- stdout : NodeJS . WriteStream ,
28+ stdout : Writer ,
2929 config : SentryConfig ,
3030 showToken : boolean
3131) : void {
@@ -46,7 +46,7 @@ function writeTokenInfo(
4646/**
4747 * Write default settings
4848 */
49- async function writeDefaults ( stdout : NodeJS . WriteStream ) : Promise < void > {
49+ async function writeDefaults ( stdout : Writer ) : Promise < void > {
5050 const defaultOrg = await getDefaultOrganization ( ) ;
5151 const defaultProject = await getDefaultProject ( ) ;
5252
@@ -66,7 +66,7 @@ async function writeDefaults(stdout: NodeJS.WriteStream): Promise<void> {
6666/**
6767 * Verify credentials by fetching organizations
6868 */
69- async function verifyCredentials ( stdout : NodeJS . WriteStream ) : Promise < void > {
69+ async function verifyCredentials ( stdout : Writer ) : Promise < void > {
7070 stdout . write ( "\nVerifying credentials...\n" ) ;
7171
7272 try {
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ type GetFlags = {
2626 * @param detectedFrom - Optional source description for auto-detection
2727 */
2828function writeHumanOutput (
29- stdout : NodeJS . WriteStream ,
29+ stdout : Writer ,
3030 event : SentryEvent ,
3131 detectedFrom ?: string
3232) : void {
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ async function tryGetLatestEvent(
4343 * Write human-readable issue output
4444 */
4545function writeHumanOutput (
46- stdout : NodeJS . WriteStream ,
46+ stdout : Writer ,
4747 issue : SentryIssue ,
4848 event ?: SentryEvent
4949) : void {
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ function parseSort(value: string): SortValue {
4848 * Write the issue list header with column titles.
4949 */
5050function writeListHeader (
51- stdout : NodeJS . WriteStream ,
51+ stdout : Writer ,
5252 org : string ,
5353 project : string ,
5454 count : number
@@ -61,10 +61,7 @@ function writeListHeader(
6161/**
6262 * Write formatted issue rows to stdout.
6363 */
64- function writeIssueRows (
65- stdout : NodeJS . WriteStream ,
66- issues : SentryIssue [ ]
67- ) : void {
64+ function writeIssueRows ( stdout : Writer , issues : SentryIssue [ ] ) : void {
6865 for ( const issue of issues ) {
6966 stdout . write ( `${ formatIssueRow ( issue ) } \n` ) ;
7067 }
@@ -73,7 +70,7 @@ function writeIssueRows(
7370/**
7471 * Write footer with usage tip.
7572 */
76- function writeListFooter ( stdout : NodeJS . WriteStream ) : void {
73+ function writeListFooter ( stdout : Writer ) : void {
7774 stdout . write (
7875 "\nTip: Use 'sentry issue get <SHORT_ID>' to view issue details.\n"
7976 ) ;
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ type GetFlags = {
2323 * @param detectedFrom - Optional source description if org was auto-detected
2424 */
2525function writeHumanOutput (
26- stdout : NodeJS . WriteStream ,
26+ stdout : Writer ,
2727 org : Parameters < typeof formatOrgDetails > [ 0 ] ,
2828 detectedFrom ?: string
2929) : void {
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ type GetFlags = {
2424 * @param detectedFrom - Optional source description if project was auto-detected
2525 */
2626function writeHumanOutput (
27- stdout : NodeJS . WriteStream ,
27+ stdout : Writer ,
2828 project : Parameters < typeof formatProjectDetails > [ 0 ] ,
2929 detectedFrom ?: string
3030) : void {
Original file line number Diff line number Diff line change @@ -82,15 +82,15 @@ function filterByPlatform(
8282/**
8383 * Write the column header row for project list output.
8484 */
85- function writeHeader ( stdout : NodeJS . WriteStream , slugWidth : number ) : void {
85+ function writeHeader ( stdout : Writer , slugWidth : number ) : void {
8686 stdout . write ( `${ "SLUG" . padEnd ( slugWidth ) } ${ "PLATFORM" . padEnd ( 20 ) } NAME\n` ) ;
8787}
8888
8989/**
9090 * Write formatted project rows to stdout.
9191 */
9292function writeRows (
93- stdout : NodeJS . WriteStream ,
93+ stdout : Writer ,
9494 projects : ProjectWithOrg [ ] ,
9595 slugWidth : number ,
9696 showOrg : boolean
Original file line number Diff line number Diff line change 22 * JSON output utilities
33 */
44
5+ import type { Writer } from "../../types/index.js" ;
6+
57/**
68 * Format data as pretty-printed JSON
79 */
@@ -12,6 +14,6 @@ export function formatJson<T>(data: T): string {
1214/**
1315 * Output JSON to a write stream
1416 */
15- export function writeJson < T > ( stream : NodeJS . WriteStream , data : T ) : void {
17+ export function writeJson < T > ( stream : Writer , data : T ) : void {
1618 stream . write ( `${ formatJson ( data ) } \n` ) ;
1719}
Original file line number Diff line number Diff line change @@ -24,3 +24,14 @@ export type {
2424 SentryOrganization ,
2525 SentryProject ,
2626} from "./sentry.js" ;
27+
28+ // I/O types
29+
30+ /**
31+ * Simple writer interface for output streams.
32+ * Compatible with process.stdout, process.stderr, and test mocks.
33+ * Avoids dependency on Node.js-specific types like NodeJS.WriteStream.
34+ */
35+ export type Writer = {
36+ write ( data : string ) : void ;
37+ } ;
You can’t perform that action at this time.
0 commit comments