From c474cd5c6c5ad642b00efa2b33115fa4a6baf14e Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 6 Nov 2025 14:33:10 -0600 Subject: [PATCH] Fix linter issues --- src/components/PluginsSection.tsx | 9 ++++----- src/hooks/usePluginGitInfo.ts | 20 ++++++++++++++++++++ src/hooks/usePlugins.ts | 17 +++++------------ 3 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 src/hooks/usePluginGitInfo.ts diff --git a/src/components/PluginsSection.tsx b/src/components/PluginsSection.tsx index e160df49..f8b137e3 100644 --- a/src/components/PluginsSection.tsx +++ b/src/components/PluginsSection.tsx @@ -7,13 +7,14 @@ import { Label } from '@/components/ui/label'; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'; import { Separator } from '@/components/ui/separator'; import { usePlugins } from '@/hooks/usePlugins'; +import { usePluginGitInfo } from '@/hooks/usePluginGitInfo'; import { useToast } from '@/hooks/useToast'; import { Alert, AlertDescription } from '@/components/ui/alert'; export function PluginsSection() { const { t } = useTranslation(); const { toast } = useToast(); - const { plugins, skills, clonePlugin, syncPlugin, deletePlugin, getPluginGitInfo } = usePlugins(); + const { plugins, skills, clonePlugin, syncPlugin, deletePlugin } = usePlugins(); const [gitUrl, setGitUrl] = useState(''); const handleAddPlugin = async () => { @@ -108,7 +109,6 @@ export function PluginsSection() { isDeleting={isDeleting} onSync={handleSyncPlugin} onDelete={handleDeletePlugin} - getPluginGitInfo={getPluginGitInfo} />; })} @@ -180,12 +180,11 @@ interface PluginItemProps { isDeleting: boolean; onSync: (pluginName: string) => void; onDelete: (pluginName: string) => void; - getPluginGitInfo: (pluginName: string) => { data: { commitHash: string; commitDate: Date; commitMessage: string } | null | undefined; isLoading: boolean }; } -function PluginItem({ pluginName, pluginSkills, isSyncing, isDeleting, onSync, onDelete, getPluginGitInfo }: PluginItemProps) { +function PluginItem({ pluginName, pluginSkills, isSyncing, isDeleting, onSync, onDelete }: PluginItemProps) { const { t } = useTranslation(); - const { data: gitInfo } = getPluginGitInfo(pluginName); + const { data: gitInfo } = usePluginGitInfo(pluginName); return ( diff --git a/src/hooks/usePluginGitInfo.ts b/src/hooks/usePluginGitInfo.ts new file mode 100644 index 00000000..e3dc8470 --- /dev/null +++ b/src/hooks/usePluginGitInfo.ts @@ -0,0 +1,20 @@ +import { useQuery } from '@tanstack/react-query'; +import { useFS } from './useFS'; +import { useFSPaths } from './useFSPaths'; +import { getPluginGitInfo } from '@/lib/plugins'; + +/** + * Hook to get git info for a specific plugin + */ +export function usePluginGitInfo(pluginName: string) { + const { fs } = useFS(); + const { pluginsPath } = useFSPaths(); + + return useQuery({ + queryKey: ['plugin-git-info', pluginsPath, pluginName], + queryFn: async () => { + return await getPluginGitInfo(fs, pluginsPath, pluginName); + }, + enabled: !!pluginName, + }); +} diff --git a/src/hooks/usePlugins.ts b/src/hooks/usePlugins.ts index 5ff4d3ad..79648793 100644 --- a/src/hooks/usePlugins.ts +++ b/src/hooks/usePlugins.ts @@ -1,7 +1,7 @@ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { useFS } from './useFS'; import { useFSPaths } from './useFSPaths'; -import { getPlugins, getAllSkills, deletePlugin as deletePluginFn, getPluginGitInfo, type PluginGitInfo } from '@/lib/plugins'; +import { getPlugins, getAllSkills, deletePlugin as deletePluginFn } from '@/lib/plugins'; import { useGit } from './useGit'; import { join } from 'path-browserify'; @@ -91,6 +91,10 @@ export function usePlugins() { dir: pluginDir, singleBranch: true, fastForward: true, + author: { + name: 'shakespeare.diy', + email: 'assistant@shakespeare.diy', + }, }); return pluginName; @@ -115,16 +119,6 @@ export function usePlugins() { }, }); - // Function to get git info for a specific plugin - const getPluginGitInfoQuery = (pluginName: string) => { - return useQuery({ - queryKey: ['plugin-git-info', pluginsPath, pluginName], - queryFn: async () => { - return await getPluginGitInfo(fs, pluginsPath, pluginName); - }, - }); - }; - return { plugins: pluginsQuery.data || [], isLoadingPlugins: pluginsQuery.isLoading, @@ -133,6 +127,5 @@ export function usePlugins() { clonePlugin, syncPlugin, deletePlugin, - getPluginGitInfo: getPluginGitInfoQuery, }; }