Skip to content

Commit fbd5b8c

Browse files
committed
feat: added log messages for any commands that failed
1 parent 6e2e0df commit fbd5b8c

2 files changed

Lines changed: 45 additions & 26 deletions

File tree

src/ui/components/widgets/ApplyComplete.tsx

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,45 @@ export function ApplyComplete({ result }: { result: ApplyResult }) {
1111

1212
const validationErrors = isPartial
1313
? result.errors
14-
.filter((e) => e.errorData.errorType === 'apply_validation')
15-
.map((e) => new ResourcePlan((e.errorData.data as any).plan))
14+
.filter((e) => e.errorData.errorType === 'apply_validation')
15+
.map((e) => ({
16+
plan: new ResourcePlan((e.errorData.data as any).plan),
17+
logs: ((e.errorData.data as any).logs ?? []) as string[],
18+
}))
1619
: [];
1720

1821
const genericErrors = isPartial
1922
? result.errors
20-
.filter((e) => e.errorData.errorType !== 'apply_validation')
21-
.map((e) => e.message)
23+
.filter((e) => e.errorData.errorType !== 'apply_validation')
24+
.map((e) => e.message)
2225
: [];
2326

2427
return (
2528
<Box flexDirection="column" marginTop={1}>
26-
<Text bold color={isPartial ? 'red' : 'green'}>
27-
{isPartial ? '⚠ Apply completed with errors' : '🎉 Finished applying 🎉'}
28-
</Text>
29-
30-
{result.entries.length > 0 && (
31-
<Box flexDirection="column" marginTop={1}>
32-
{result.entries.map((entry) => (
33-
<Box key={entry.id}>
34-
<Text>{entry.id.padEnd(30)}</Text>
35-
<Text color={applyEntryInkColor(entry)}>{applyEntryLabel(entry)}</Text>
36-
</Box>
37-
))}
38-
</Box>
39-
)}
40-
4129
{validationErrors.length > 0 && (
4230
<Box flexDirection="column" marginTop={1}>
43-
{validationErrors.map((resourcePlan) => (
44-
<Box key={resourcePlan.id} flexDirection="column">
31+
{validationErrors.map((entry) => (
32+
<Box key={entry.plan.id} flexDirection="column">
4533
<Text color="red" bold>
46-
{`Apply failed: resource "${resourcePlan.id}" did not reach its desired state.`}
34+
{`Apply failed: resource "${entry.plan.id}" did not reach its desired state.`}
4735
</Text>
4836
<Text> </Text>
4937
<Text bold backgroundColor={'red'}>Changes still needed:</Text>
50-
<Text>{prettyFormatResourcePlan(resourcePlan)}</Text>
38+
<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+
)}
5145
<Text> </Text>
5246
</Box>
5347
))}
5448
<Text color="red" bold>Potential fixes:</Text>
55-
<Text color="red" bold>{' 1. Re-run the command again'}</Text>
56-
<Text color="red" bold>{' 2. Manually install the resource and retry'}</Text>
57-
<Text color="red" bold>{' 3. Reach out to support at https://github.com/codifycli/default-plugin/issues'}</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>
5853
</Box>
5954
)}
6055

@@ -64,6 +59,28 @@ export function ApplyComplete({ result }: { result: ApplyResult }) {
6459
</Box>
6560
)}
6661

62+
63+
{isPartial && <Box marginTop={1}>
64+
<Text dimColor>{'─'.repeat(40)}</Text>
65+
</Box>}
66+
67+
<Box marginTop={isPartial ? 0 : 1}>
68+
<Text bold color={isPartial ? 'red' : 'green'}>
69+
{isPartial ? '⚠ Apply completed with errors' : '🎉 Finished applying 🎉'}
70+
</Text>
71+
</Box>
72+
73+
{result.entries.length > 0 && (
74+
<Box flexDirection="column">
75+
{result.entries.map((entry) => (
76+
<Box key={entry.id}>
77+
<Text>{entry.id.padEnd(30)}</Text>
78+
<Text color={applyEntryInkColor(entry)}>{applyEntryLabel(entry)}</Text>
79+
</Box>
80+
))}
81+
</Box>
82+
)}
83+
6784
{!isPartial && (
6885
<Box marginTop={1}>
6986
<Text dimColor>Open a new terminal or source &apos;.zshrc&apos; for the new changes to be reflected</Text>

src/ui/plugin-error-formatter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import { prettyFormatResourcePlan } from './plan-pretty-printer.js';
44

55
export function formatApplyValidationError(error: PluginError): string {
66
const plan = new ResourcePlan((error.errorData.data as any).plan);
7+
const logs: string[] = (error.errorData.data as any).logs ?? [];
78
return [
89
`Apply validation failed: resource "${plan.id}" did not reach its desired state.`,
910
'Changes still needed:',
1011
prettyFormatResourcePlan(plan),
12+
...(logs.length > 0 ? ['', `Last ${logs.length} log lines:`, logs.join('\n')] : []),
1113
].join('\n');
1214
}

0 commit comments

Comments
 (0)