Skip to content

Commit 78d76e5

Browse files
committed
feat: improved error logs. Made it visually more appealing
1 parent fbd5b8c commit 78d76e5

1 file changed

Lines changed: 40 additions & 32 deletions

File tree

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Static, Text } from 'ink';
1+
import { Box, Text } from 'ink';
22
import React from 'react';
33

44
import { ApplyResult } from '../../../entities/apply-result.js';
@@ -26,55 +26,62 @@ export function ApplyComplete({ result }: { result: ApplyResult }) {
2626

2727
return (
2828
<Box flexDirection="column" marginTop={1}>
29-
{validationErrors.length > 0 && (
30-
<Box flexDirection="column" marginTop={1}>
31-
{validationErrors.map((entry) => (
32-
<Box key={entry.plan.id} flexDirection="column">
33-
<Text color="red" bold>
34-
{`Apply failed: resource "${entry.plan.id}" did not reach its desired state.`}
35-
</Text>
36-
<Text> </Text>
37-
<Text bold backgroundColor={'red'}>Changes still needed:</Text>
29+
30+
{validationErrors.map((entry) => (
31+
<Box key={entry.plan.id} flexDirection="column" marginBottom={1}>
32+
<Box>
33+
<Text color="red" bold>{'● FAILED '}</Text>
34+
<Text bold>{entry.plan.id}</Text>
35+
</Box>
36+
<Box flexDirection="column" borderStyle="single" borderColor="red" borderRight={false} borderTop={false} borderBottom={false} paddingLeft={1} marginLeft={1} marginTop={1}>
37+
<Text dimColor>Resource did not reach its desired state after apply.</Text>
38+
<Box flexDirection="column" marginTop={1}>
39+
<Text bold>Changes still needed:</Text>
3840
<Text>{prettyFormatResourcePlan(entry.plan)}</Text>
39-
{entry.logs.length > 0 && (
40-
<Box flexDirection="column" marginTop={1}>
41-
<Text bold>{`Last ${entry.logs.length} log lines:`}</Text>
42-
<Text>{entry.logs.join('\n')}</Text>
43-
</Box>
44-
)}
45-
<Text> </Text>
4641
</Box>
47-
))}
48-
<Text color="red" bold>Potential fixes:</Text>
49-
<Text color="red" bold>{' 1. Re-run with verbose logging (--verbose or press \'v\' during apply)'}</Text>
50-
<Text color="red" bold>{' 2. Manually install the failed resource'}</Text>
51-
<Text color="red"
52-
bold>{' 3. Reach out to support at https://github.com/codifycli/default-plugin/issues'}</Text>
42+
{entry.logs.length > 0 && (
43+
<Box flexDirection="column" marginTop={1}>
44+
<Text bold>Apply output:</Text>
45+
<Text dimColor>{entry.logs.join('\n')}</Text>
46+
</Box>
47+
)}
48+
</Box>
5349
</Box>
54-
)}
50+
))}
5551

5652
{genericErrors.length > 0 && (
57-
<Box flexDirection="column" marginTop={1}>
58-
{genericErrors.map((msg, i) => <Text key={i} color="red">{msg}</Text>)}
53+
<Box flexDirection="column" marginBottom={1}>
54+
{genericErrors.map((msg, i) => (
55+
<Box key={i}>
56+
<Text color="red" bold>{'● ERROR '}</Text>
57+
<Text>{msg}</Text>
58+
</Box>
59+
))}
5960
</Box>
6061
)}
6162

63+
{isPartial && (
64+
<Box flexDirection="column" marginBottom={1}>
65+
<Text color="red" bold>Potential fixes:</Text>
66+
<Text color="red">{' 1. Re-run with verbose logging (--verbose or press \'v\' during apply)'}</Text>
67+
<Text color="red">{' 2. Manually install the failed resource and retry'}</Text>
68+
<Text color="red">{' 3. Reach out to support at https://github.com/codifycli/default-plugin/issues'}</Text>
69+
</Box>
70+
)}
6271

63-
{isPartial && <Box marginTop={1}>
64-
<Text dimColor>{'─'.repeat(40)}</Text>
65-
</Box>}
72+
<Text dimColor>{'─'.repeat(40)}</Text>
6673

67-
<Box marginTop={isPartial ? 0 : 1}>
74+
<Box marginTop={1}>
6875
<Text bold color={isPartial ? 'red' : 'green'}>
6976
{isPartial ? '⚠ Apply completed with errors' : '🎉 Finished applying 🎉'}
7077
</Text>
7178
</Box>
7279

7380
{result.entries.length > 0 && (
74-
<Box flexDirection="column">
81+
<Box flexDirection="column" marginTop={1}>
7582
{result.entries.map((entry) => (
7683
<Box key={entry.id}>
77-
<Text>{entry.id.padEnd(30)}</Text>
84+
<Text dimColor={entry.status === 'skipped'}>{entry.id.padEnd(30)}</Text>
7885
<Text color={applyEntryInkColor(entry)}>{applyEntryLabel(entry)}</Text>
7986
</Box>
8087
))}
@@ -86,6 +93,7 @@ export function ApplyComplete({ result }: { result: ApplyResult }) {
8693
<Text dimColor>Open a new terminal or source &apos;.zshrc&apos; for the new changes to be reflected</Text>
8794
</Box>
8895
)}
96+
8997
</Box>
9098
);
9199
}

0 commit comments

Comments
 (0)