@@ -8,14 +8,14 @@ import type {
8
8
Problem ,
9
9
ResolutionKind ,
10
10
ProblemKind ,
11
- } from 'are-the-types-wrong- core'
11
+ } from '@arethetypeswrong/ core'
12
12
import {
13
13
checkTgz ,
14
14
summarizeProblems ,
15
15
getProblems ,
16
- } from 'are-the-types-wrong- core'
16
+ } from '@arethetypeswrong/ core'
17
17
import React from 'react'
18
- import { render , Text , Box } from 'ink'
18
+ import { render , Text , Box , Static } from 'ink'
19
19
20
20
const allResolutionKinds : ResolutionKind [ ] = [
21
21
'node10' ,
@@ -34,6 +34,8 @@ const problemEmoji: Record<ProblemKind, string> = {
34
34
FallbackCondition : '🐛' ,
35
35
CJSOnlyExportsDefault : '🤨' ,
36
36
FalseExportDefault : '❗️' ,
37
+ UnexpectedESMSyntax : '🚭' ,
38
+ UnexpectedCJSSyntax : '🚱' ,
37
39
}
38
40
39
41
const problemShortDescriptions : Record < ProblemKind , string > = {
@@ -46,6 +48,8 @@ const problemShortDescriptions: Record<ProblemKind, string> = {
46
48
FallbackCondition : `${ problemEmoji . FallbackCondition } Used fallback condition` ,
47
49
CJSOnlyExportsDefault : `${ problemEmoji . CJSOnlyExportsDefault } CJS default export` ,
48
50
FalseExportDefault : `${ problemEmoji . FalseExportDefault } Incorrect default export` ,
51
+ UnexpectedESMSyntax : `${ problemEmoji . UnexpectedESMSyntax } Unexpected ESM syntax` ,
52
+ UnexpectedCJSSyntax : `${ problemEmoji . UnexpectedCJSSyntax } Unexpected CJS syntax` ,
49
53
}
50
54
51
55
const resolutionKinds : Record < ResolutionKind , string > = {
@@ -92,6 +96,7 @@ function Traces({
92
96
if ( ! ( 'entrypointResolutions' in analysis ) ) {
93
97
return null
94
98
}
99
+
95
100
return (
96
101
< Box flexDirection = "column" width = "100%" >
97
102
{ subpaths . map ( ( subpath ) => {
@@ -101,15 +106,27 @@ function Traces({
101
106
return (
102
107
< Box width = "100%" key = { 'traces-' + subpath } flexDirection = "column" >
103
108
< Text color = "blue" bold >
104
- { subpath }
109
+ Traces for Subpath: { subpath }
105
110
</ Text >
106
111
{ resolutionDetails . map ( ( [ resolutionKind , details ] ) => {
107
112
return (
108
- < Box width = "100%" key = { subpath } flexDirection = "column" >
113
+ < Box
114
+ width = "100%"
115
+ key = { `resolutionDetails-${ resolutionKind } -${ subpath } ` }
116
+ flexDirection = "column"
117
+ >
109
118
< Text bold > { resolutionKind } Traces:</ Text >
110
- { details . trace . map ( ( traceLine , i ) => {
111
- return < Text key = { i } > { traceLine } </ Text >
112
- } ) }
119
+ < Box flexDirection = "column" >
120
+ { details . trace . map ( ( traceLine , i ) => {
121
+ return (
122
+ < Text
123
+ key = { `resolutionDetails-traces-${ subpath } -${ resolutionKind } -${ i } ` }
124
+ >
125
+ { traceLine }
126
+ </ Text >
127
+ )
128
+ } ) }
129
+ </ Box >
113
130
</ Box >
114
131
)
115
132
} ) }
@@ -182,7 +199,8 @@ function ChecksTable(props: { checks?: Checks }) {
182
199
} else {
183
200
content = (
184
201
< Text >
185
- { '✅ ' + moduleKinds [ resolution ?. moduleKind || '' ] }
202
+ { '✅ ' +
203
+ moduleKinds [ resolution ?. moduleKind ?. detectedKind || '' ] }
186
204
</ Text >
187
205
)
188
206
}
@@ -234,7 +252,16 @@ function ChecksTable(props: { checks?: Checks }) {
234
252
}
235
253
}
236
254
237
- render ( < ChecksTable checks = { checks } /> )
255
+ // Ink will duplicate all of its output if it is longer than the terminal height.
256
+ // Known bug with the underlying rendering: https://github.com/vadimdemedes/ink/issues/48
257
+ // Solution is to mark the entire content as "static" so it won't get updated, but flushed.
258
+ render (
259
+ < Static items = { [ checks ] } >
260
+ { ( checks : Checks , index : number ) => {
261
+ return < ChecksTable key = { `checks-${ index } ` } checks = { checks } />
262
+ } }
263
+ </ Static >
264
+ )
238
265
239
266
const exitCode = checks . problems ?. length ?? 0
240
267
process . exit ( exitCode )
0 commit comments