import { Box, Text } from "ink"; import type { Configuration } from "../sync/index.js"; import { push } from "../sync/orchestrate.js"; import { ResourceResults, useSyncCommand, Warnings } from "./sync-command.js"; type PushProps = Configuration & { dryRun?: boolean }; export default function Push(configuration: PushProps) { const state = useSyncCommand(() => push(configuration), [configuration]); const warnings = state.status === "running" || state.status === "done" || state.status === "dry_run" ? state.warnings : []; return ( {state.status === "error" ? ( Error: {state.error} ) : state.status === "dry_run" ? ( <> {state.changes.length === 0 ? ( No changes to push. ) : ( <> Would push the following changes: {state.changes.map(({ resource, count }) => ( {` ${resource}: ${count} changed`} ))} )} No changes made. ) : state.status === "done" ? ( Object.keys(state.stats).length === 0 ? ( Everything up to date. ) : ( ) ) : state.status === "running" ? ( Pushing... ) : null} ); }