@t1mmen/srtd
Version:
Supabase Repeatable Template Definitions (srtd): 🪄 Live-reloading SQL templates for Supabase DX. Make your database changes reviewable and migrations maintainable! 🚀
44 lines • 2.75 kB
JavaScript
import figures from 'figures';
import { Box, Text } from 'ink';
import React from 'react';
import { StatBadge } from './StatBadge.js';
import { COLOR_ERROR, COLOR_SKIP, COLOR_SUCCESS } from './customTheme.js';
function ResultSection({ items, label, variant, }) {
if (items.length === 0)
return null;
const icon = variant === 'build' ? figures.tick : variant === 'apply' ? figures.play : figures.pointerSmall;
const maxItems = 30;
const itemsToShow = items.slice(0, maxItems);
const overflow = items.length > maxItems ? `... and ${items.length - maxItems} more` : '';
const color = variant === 'skip' ? COLOR_SKIP : COLOR_SUCCESS;
return (React.createElement(Box, { flexDirection: "column" },
React.createElement(Text, { bold: true },
label,
":"),
React.createElement(Box, { marginLeft: 2, flexDirection: "column" },
itemsToShow.map(item => (React.createElement(Text, { key: item, color: color },
icon,
" ",
item))),
overflow && React.createElement(Text, { dimColor: true }, overflow))));
}
export function ProcessingResults({ result, showBuild = true, showApply = false }) {
return (React.createElement(Box, { flexDirection: "column", gap: 1 },
React.createElement(ResultSection, { items: result.skipped, label: "Skipped", variant: "skip" }),
showBuild && React.createElement(ResultSection, { items: result.built, label: "Built", variant: "build" }),
showApply && React.createElement(ResultSection, { items: result.applied, label: "Applied", variant: "apply" }),
result.errors.length > 0 && (React.createElement(Box, { flexDirection: "column" },
React.createElement(Text, { color: COLOR_ERROR }, "Errors:"),
result.errors.map(error => (React.createElement(Text, { key: error.file, color: COLOR_ERROR },
figures.cross,
" ",
error.templateName,
": ",
error.error))))),
React.createElement(Box, { marginBottom: 1, gap: 1 },
result.skipped.length > 0 && (React.createElement(StatBadge, { label: "Skipped", value: result.skipped.length, color: COLOR_SKIP })),
result.errors.length > 0 && (React.createElement(StatBadge, { label: "Errors", value: result.errors.length, color: COLOR_ERROR })),
result.built.length > 0 && (React.createElement(StatBadge, { label: "Built", value: result.built.length, color: COLOR_SUCCESS })),
result.applied.length > 0 && (React.createElement(StatBadge, { label: "Applied", value: result.applied.length, color: COLOR_SUCCESS })))));
}
//# sourceMappingURL=ProcessingResults.js.map